2017-07-05 90 views

回答

0

您可以在Windows Phone應用程序中獲得SIM MSISDN & IMSI號碼。請注意,您應按如下方式手動編輯應用程序Package.appxmanifest:

<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> 

的cellularDeviceIdentity能力允許應用訪問蜂窩識別數據。 任何人都可以請求訪問這些capabilities以進行商店提交。

您可以使用MobileBroadbandModem類獲取全部CurrentDeviceInformation,以下是核心代碼。

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(); 
} 

我已經將code sample上傳到git hub。請檢查!

+0

如何獲取windows.networking.networkoperators的參考? –

+0

你可以直接使用['Windows.Networking.NetworkOperators'](https://docs.microsoft.com/en-us/uwp/api/windows.networking.networkoperators)命名空間! –

+0

我沒有得到代碼中可訪問的MobileBroadbandModem類。我已將 添加到Package.appxmanifest中。但我正在使用VS2013並使Windows Phone 8.1應用程序 –

相關問題