Search code examples
windows-phone-8push-notificationparse-platformmpns

Push Notification not received by windows phone app : Parse


I have followed all the steps given in the documentation to register for a push notification from the Parse website. (All the steps in the sense I downloaded the default project and added event handler to handle the incoming toast notification).

      ParseClient.Initialize("x0uNa3Q164SVGKbH4mxZJaxWxsuYtslB5tVPj893",
          "cXFv9RQAoray9xFdwdcZCHXrrkrM6KNd0WyN194H");


      this.Startup += async (sender, args) =>
      {
          // This optional line tracks statistics around app opens, including push effectiveness:
          ParseAnalytics.TrackAppOpens(RootFrame);

          // By convention, the empty string is considered a "Broadcast" channel
          // Note that we had to add "async" to the definition to use the await keyword
          await ParsePush.SubscribeAsync("");

      };

      ParsePush.ToastNotificationReceived += ParsePushOnToastNotificationReceived;

and the handler

      private void ParsePushOnToastNotificationReceived(object sender, 
      NotificationEventArgs notificationEventArgs)
  {
      var s = new ShellToast();
      s.Content = notificationEventArgs.Collection.Values.First();
      s.Title = "My Toast";
      s.Show();

  }


      private async void Application_Launching(object sender, LaunchingEventArgs e) 
  {
    await ParseAnalytics.TrackAppOpenedAsync();
  }

When I run the app in the emulator it registers the app and I can verify it in my dashboard. But as soon as I send push notification from the website number of registered devices will be shown as 0 and the app doesnt receive the notification.

One thing to mention is this behavior is not consistent. Sometimes the app does receive the notification. Can anyone mention the reason for this or any other point I am missing?

Number of recipients = 1 Number of recipients became 0


Solution

  • One thing to note is that ShellToast.Show() should only be used from background task. If you call it when an app is in the foreground, toast won't be shown. http://msdn.microsoft.com/en-US/library/windowsphone/develop/microsoft.phone.shell.shelltoast.show(v=vs.105).aspx So, be sure your app is not in the foreground when you expect to see toast notification.