I'm having the following problem with UWP push notifications.
Scenario:
Foreground registers a background task for push notifications but also wants to be notified of incoming pushes so it gets a channel, updates the server with the channel then hooks onto events on that channel.
Push notification comes in
- Background task launches and does it's work. It also checks to see if the channel URI has changed, if it has, it updates the server with the new uri.
Result:
Foreground app no longer receives incoming pushes on the channel because the background task updated the server with a different channel uri from what the foreground app was listening on.
What is the proper way for the foreground app to continue listening for push notifications after the uri potentially changed?
Updated problem for clarification:
Step 1 Foreground app code:
var channel = await PushNotificationChannelManager.CreatePushNotificationChannelForApplicationAsync();
channel.PushNotificationReceived += OnPushNotificationReceived;
//<update server with channel.Uri
Step 2 Background task launches and also checks for a new channel uri:
var channel = await PushNotificationChannelManager.CreatePushNotificationChannelForApplicationAsync();
//update server with channel uri
Problem
If channel uri changes in Step 2 then the even handler in Step 1 never gets invoked again.