-1

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.

Jigar Shah
  • 175
  • 2
  • 3
  • 13

1 Answers1

0

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!

Nico Zhu
  • 32,367
  • 2
  • 15
  • 36
  • How can I get the reference of the windows.networking.networkoperators? – Jigar Shah Jul 06 '17 at 09:25
  • You could use [`Windows.Networking.NetworkOperators`](https://learn.microsoft.com/en-us/uwp/api/windows.networking.networkoperators) name space directly ! – Nico Zhu Jul 06 '17 at 09:51
  • I am not getting the MobileBroadbandModem class accessible in the code. I have added this to the Package.appxmanifest. But I am using VS2013 and making windows phone 8.1 app – Jigar Shah Jul 06 '17 at 10:02
  • Do I need to get any kind of permission to work on this? – Jigar Shah Jul 06 '17 at 10:05
  • In 8.1 I am not able to access the MobileBroadbandModem class – Jigar Shah Jul 06 '17 at 10:13
  • Exactly, The name space of `Windows.Networking.NetworkOperators` is used in uwp! – Nico Zhu Jul 06 '17 at 10:17
  • You are right. I can use the same namespace in UWP 8.1. But I am not able to access MobileBroadbandModem class. – Jigar Shah Jul 06 '17 at 10:24
  • There are no APIs in the Windows Phone SDK to retrieve this information. Mobile Operators have to work with their Microsoft contact\Support channels available for them. Form more your cold refer to [this case](https://social.msdn.microsoft.com/Forums/windows/en-US/1cd5e507-7fed-4c62-88b8-cc1544079357/sim-card-information-iccid-imsi-msisdn?forum=wpdevelop). – Nico Zhu Jul 07 '17 at 01:42