Search code examples
windows-phonewin-universal-appwindows-10-universalwindows-10-mobile

How to find sim card availability in UWP windows phone


I am developing a UWP app, in which I want check for sim availability.

If sim is available I need activate phone call , else i will activate skype call.

I am trying different api's to get sim availability, but nothing gives exact result.

Can anyone help to get sim availability?

Thanks in advance. Noorul


Solution

  • Here is similar topic: Whether SIM card is available or not in windows phone universal project

    The code from should work also in Windows 10 because ChatMessageManager class is available also in UWP

    bool simAvailable = false;
    var device = await ChatMessageManager.GetTransportsAsync();
    if (device != null && device.Count > 0)
    {
    foreach (var item in device)
     {
        if (item.TransportFriendlyName != "No SIM")
        {
            simAvailable = true;
            break;
        }
     }
    }
    

    PS: Don't forget to add chat message access capability in your application manifest
    PPS: If you phone language is not English you will get "No SIM" message on you language (thankfully to @user1195883 comments)