locked
Unable to get default SMS device

    Question

  • Hi,

    when trying to call SmsDevice.GetDefault() I sometimes get an unexpected COM exception. Going back to documentation I read that the async operation should ship around this:

    "Because the device might be busy, the operation executes asynchronously. The asynchronous operation object returns immediately."

     

    I rewrote the code to access the device to use the async operation, but in no case the operation ever returned. Even worse, it looks as if the async operation doesn't ever execute. Here is my piece of code:

     

            public async void ReadMessagesAsync()
            {
                try
                {
                    System.Diagnostics.Debug.WriteLine("Getting device"); 
                    ISmsDevice device = await SmsDevice.GetDefaultAsync();
                    if (device == null)
                    {
                        System.Diagnostics.Debug.WriteLine("No device");
                        return;
                    }
                    System.Diagnostics.Debug.WriteLine("Reading messages");
                    IReadOnlyList<ISmsMessage> messages = await device.MessageStore.GetMessagesAsync(SmsMessageFilter.All);
                    foreach (SmsBinaryMessage message in messages)
                    {
                        SmsTextMessage smsText = SmsTextMessage.FromBinaryMessage(message);
                        System.Diagnostics.Debug.WriteLine(string.Format("From: {0}\r\n{1}", smsText.From, smsText.Body));
                    }
                }
                catch (Exception e)
                {
                    System.Diagnostics.Debug.WriteLine(e);
                }
            }

    It does never continue after hitting:

     

    ISmsDevice device = await SmsDevice.GetDefaultAsync();

     

    Can somebody help?

     

    Best regards, Michael



    Wednesday, November 9, 2011 9:32 AM

Answers

All replies

  • Hi Michael,

    What is the specific COM exception you are receiving from GetDefault()?

    Do you see the same behavior with the "Sms Send/Receive" sample?

     

    http://code.msdn.microsoft.com/windowsapps/Sms-SendReceive-fa02e55e

     

    thanks

    Frank

    Friday, November 11, 2011 5:48 PM
    Moderator
  • I'm getting exactly the same problems.

    I get the COM exception anytime my 3G USB stick is missing (which is easily remedied by plugging it in)

    Based on the sample code, I can call GetMessageAsync (Note no plural) and retrieve a message at a time, but not filtered to Unread/Read/etc, but if you call GetMessagesAsync (Note messageS) then it never returns. You will note that GetMessageS is not used in the sample


    • Edited by AlSki.net Thursday, April 5, 2012 5:19 PM
    Thursday, April 5, 2012 5:18 PM
  • I can able to send and receive SMS and retrieve the messages using the GetMessageAsync call by passing the message id.

    But When I am trying to use GetMessagesAysnc, I am seeing an error. 

    var ReadAllMessages = smsdevice.MessageStore.GetMessagesAsync(SmsMessageFilter.All);

    ReadAllMessages Errorcode "Message = "Number of parameters specified does not match the expected number."

    Rest of the APIs are working, I am seeing problems only with GetMessagesAysnc function.

    Wednesday, April 11, 2012 1:45 PM
  • This functionality is only available to mobile operator apps and Metro style apps given privileged access by mobile network operators.

    Best Wishes - Eric

    Wednesday, June 6, 2012 4:51 AM
    Moderator
  • Was this issue ever resolved? I have the same problem - getMessageAsync from returns "The parameter is incorrect" from a js app. (and I do have privileged access as I'm developing for a mobile network operator)

    Mike


    • Edited by MikeHowey Monday, July 30, 2012 10:19 AM
    Sunday, July 29, 2012 3:38 PM
  • i have authored the device metadata for my 3G datacard, and filled the SMS sample app information in the wizzard. After that, i debuged the SMS sample code, but when it hit the SmsDevice::GetDefaultAsync(), the exception HRESULT:0x80070005 always come out? does someone meet the same issue?

    Wednesday, September 5, 2012 9:09 AM
  • access denied. when i turn off the text message permission, it will show the 0X80070005 E_ACCESSDENIED error code
    Monday, September 24, 2012 1:58 PM
  • This functionality is only available to mobile operator apps and Windows Store apps given privileged access by mobile network operators, mobile broadband adapter IHV, or OEM. For more information, see Mobile Broadband: Windows Store device apps.

    Best Wishes - Eric

    Tuesday, September 25, 2012 8:02 PM
    Moderator
  • The computer must be set to the TEST MODE.
    Wednesday, October 31, 2012 8:29 AM