locked
PushNotificationReceived is not fired App is in Suspended in Windows 10 UAP. RRS feed

  • Question

  • OpenCahnnel is used to Create Channel Uri.

    public void OpenChannel()
    {
          var operation = PushNotificationChannelManager.CreatePushNotificationChannelForApplicationAsync();
          operation.Completed = OnChannelCreationCompleted;
     }

    private void OnChannelCreationCompleted(IAsyncOperation<PushNotificationChannel> asyncInfo, AsyncStatus operation)
            {

                if (asyncInfo.Status == AsyncStatus.Completed)
                {
                    channel = asyncInfo.GetResults();
                    channel.PushNotificationReceived += Channel_PushNotificationReceived;

                    // Send these values together with user data to your server of choice
                    string _pushNotificationUri = channel.Uri;
                    var expirationTime = channel.ExpirationTime;            
                }
            }

            private void Channel_PushNotificationReceived(PushNotificationChannel sender, PushNotificationReceivedEventArgs args)
            {
                string notificationContent = null;
                switch (args.NotificationType)
                {
                    case PushNotificationType.Badge:
                        notificationContent = args.BadgeNotification.Content.GetXml();
                        break;
                    case PushNotificationType.Tile:
                        notificationContent = args.TileNotification.Content.GetXml();
                        break;
                    case PushNotificationType.Toast:
                        notificationContent = args.ToastNotification.Content.GetXml();
                        break;

                    default:

                        break;

                }
                // prevent the notification from being delivered to the UI
                args.Cancel = true;
            }

    this method "OnChannelCreationCompleted" is not fired when server sends the toast Notification.



    Tuesday, February 2, 2016 6:22 AM