For my app I need to do some checks based on local phone carriers. I figured out ther开发者_Go百科e are a few possible ways to get that information on other mobile operating systems (IMSI, ...). For Windows Phone 7, I found a way to do the check on devices based on OS-versions >=7.1.
http://msdn.microsoft.com/en-us/library/microsoft.phone.net.networkinformation.devicenetworkinformation.cellularmobileoperator%28v=VS.92%29.aspx
Now my question is: is there any way to get carrier information on devices <7.1?
Thanks
IIRC, the user agent string should contain much of the information you're looking for, e.g.
Mozilla/4.0 (compatible; MSIE 7.0; Windows Phone OS 7.0; Trident/3.1; IEMobile/7.0) Asus;Galaxy6
(via http://madskristensen.net/post/Windows-Phone-7-user-agents.aspx)
the general format of the UA string is this (for Mango):
Mozilla/5.0 (compatible; MSIE 9.0; Windows Phone OS 7.5; Trident/5.0; IEMobile/9.0; <manufacturer>; <model> [;<operator])
So as you can see, the operator info may be available in the UA string, but it is not guaranteed (it is up to each carrier to decide whether to pass it or not). This applies (I believe) to OS < 7.5 also.
From the practical perspective however, it's not a very reliable method of determining the carrier. You could perhaps supplement/complement this with an IP address owner lookup -- get the phone's (3G, not wifi natch) IP and check to see which carrier owns that block of addresses. This would have the benefit of informing you of what carrier the user is currently accessing data through, which can be different from the actual carrier the user subscribes to.
Joe Healy has a great post showing a number of different UA strings from different WP7 devices here
Also, see http://blogs.msdn.com/b/iemobile/archive/2010/03/25/ladies-and-gentlemen-please-welcome-the-ie-mobile-user-agent-string.aspx
精彩评论