0

I have a UWP app for Windows 10 setup to receive Raw and Toast notifications through WNS. I can correctly receive messages while in the foreground and while suspended in the background.

In the foreground, I setup a handler PushNotificaitonChannel.PushNotificationReceived and in the handler I set args.Cancel == true once I process the message.

For background processing I register an in-process background task using a PushNotificationTrigger(). This works great except for one perplexing issue: I often receive duplicate copies of the raw notifications. The number of duplicates can range from 1-20+.

I have seen this behavior on many different generations of Windows from build 14393 through the latest released build 17763.

I can reproduce the duplicates under visual studio and noticed that the call stacks vary between the first receipt and duplicate receipts. I haven't found any state hidden in the native/COM data structures that indicate how to stop the duplicates. I can post the stack traces if that would help.

I am hoping someone else knows how to stop this -- to somehow acknowledge the receipt of the raw WNS message in an in-process background task.

Many thanks for reading and pondering this issue.

EDIT: while working on the minimal example, I uncovered the following pattern of behavior.

  1. test app in foreground, send raw push; received normally
  2. close app via normal close button; app not running
  3. send new raw push; app starts in background and receives raw push fine; app goes to suspended state
  4. (app still suspended) send new raw push; app starts running; same raw push received TWICE; app goes back to suspended
  5. this can happen any number of times and the raw push is only ever received TWICE
  6. kill app (using End Task in Task Manager); app not running
  7. send new raw push; app starts running; same raw push received TWICE (as in #4); app goes back to suspended
  8. and the most odd of all: send new raw push and the app receives raw push THREE times; app goes back to suspended
  9. now, every raw push gets received THREE times; if I kill the app again and stat sending raw push, the number of dups goes up by one.
Craig
  • 51
  • 1
  • 2
  • I spent a long time to make a UWP app to receive raw notification, and make an app as cloud service to sent raw notification to my UWP app. Then, there's no problem. It worked well. I did not receive duplicate copies of the raw notifications. My UWP app register in-process background task to receive raw notification. My OS build version is 17763.107. My UWP project's target version is 17763. To help you more on this question, please provide a [mcve]. – Xie Steven Dec 27 '18 at 06:28
  • The fact that you have a working, if small, example is great and gives me confidence in the value of spending the time to create a small example of my own. – Craig Dec 28 '18 at 17:39

0 Answers0