0
votes

I am developing a WP8.1 silverlight app, that receives WNS notification. It works fine on the emulator, but on the device (lumia 640), it crashes at the following api call:

var channel = await Windows.Networking.PushNotifications.PushNotificationChannelManager.CreatePushNotificationChannelForApplicationAsync();

I receive the following error:

  • _exception {System.Exception: Exception from HRESULT: 0x880403E8 at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Runtime.CompilerServices.TaskAwaiter1.GetResult() at BC_Menu.App.<UploadChannel>d__0.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Runtime.CompilerServices.TaskAwaiter1.GetResult() at BC_Menu.StartUp.FirstPage.d__4.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.AsyncMethodBuilderCore.b__3(Object state)} System.Exception

If I try on another device (lumia 920), it works fine. The immediate difference between the devices are that I have a dummy account on the Lumia 640 and no sim card, but I am able to install and update programs. Which should mean the account is correctly initialized. What else could be the issue?

1

1 Answers

0
votes

You're crashing because the Windows.Networking.PushNotifications.PushNotificationChannelManager.CreatePushNotificationChannelForApplicationAsync() call is throwing an exception because the device is not connected to WNS. Make sure you handle that case (e.g. with a try/catch) - your users may not always be connected to the internet, which is required to get a channel.

As for why that device isn't connecting to WNS - if you have no SIM card, the device should connect via Wi-Fi. If you're developing in an enterprise make sure they're not blocking outbound connections (which would cause the device to be unable to connect to WNS). If you have a SIM card installed but it has no data, there is a known bug where the device will still try to connect via cellular data (which of course fails). If that's the case, just remove the data-less SIM or disable cellular.