Get SIM MSISDN & IMSI number in Windows Phone Application

浪尽此生 提交于 2019-12-14 03:22:09

问题


Is it possible to get the SIM MSISDN & IMSI number in windows Phone app development?

I have gone through some of the Q/A but they all are asked a long time ago.


回答1:


You could get SIM MSISDN & IMSI number in Windows Phone Application. Please notice that you should manually edit your application Package.appxmanifest as follows:

<Package xmlns="http://schemas.microsoft.com/appx/manifest/foundation/windows10" 
    xmlns:mp="http://schemas.microsoft.com/appx/2014/phone/manifest"
    xmlns:uap="http://schemas.microsoft.com/appx/manifest/uap/windows10"
    xmlns:rescap="http://schemas.microsoft.com/appx/manifest/foundation/windows10/restrictedcapabilities"
    IgnorableNamespaces="uap mp rescap">

......

<Capabilities>
    <rescap:Capability Name="cellularDeviceIdentity" />
</Capabilities>

The cellularDeviceIdentity capability allows apps to access cellular identification data. Anyone may request access to these capabilities for store submission.

You could use MobileBroadbandModem class to get all CurrentDeviceInformation, and the following is core codes.

using Windows.Networking.NetworkOperators;

......

public IReadOnlyList<SimCard> GetSimCards()
{
    var results = new List<SimCard>();

    var modem = MobileBroadbandModem.GetDefault();
    if (modem == null)
    {
        return results.AsReadOnly();
    }

    var account = modem.CurrentAccount;
    if (account == null)
    {
        return results.AsReadOnly();
    }
    var simCard = new SimCard();
    simCard.ICCID = account.CurrentDeviceInformation.SimIccId;
    simCard.IMSI = account.CurrentDeviceInformation.SubscriberId;
    simCard.MSISDN = modem.DeviceInformation.TelephoneNumbers;

    simCard.MCC = ExtractMCC(simCard.IMSI);
    simCard.MNC = ExtractMNC(simCard.IMSI);
    simCard.MSID = ExtractMSID(simCard.IMSI);

    results.Add(simCard);

    return results.AsReadOnly();
}

I have uploaded code sample to git hub. Please check!



来源:https://stackoverflow.com/questions/44927821/get-sim-msisdn-imsi-number-in-windows-phone-application

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!