0
votes

I have a background task for a UWP which can be triggered once a push notification occurs, but I want to trigger the task for normal toast notifications activated when the App is in background.

I found that ToastNotificationActionTrigger can do so but it can only trigger the BG task when the activation type is set to background for that notification.

Is there a work around for differentiating when a toast notification is received and activated with App in BG with that of a toast notification activated in Foreground.

1
Why don't you just set the activation type of the toast to Background? That's how you make a toast activate a background task when clicked rather than launching your app.Andrew Leader
Because the toast notification is not specific for Background only. The case is that the notification can be received anytime in the BG or Foreground. It just that a difference at what App state it was tapped is requiredTulika
Your scenario still isn't making sense. Can you more clearly describe the exact scenario from the user's perspective?Andrew Leader

1 Answers

0
votes

ToastNotification class has an Activated event so you can attach an event handler once you create it to receive Activation events without a background task.

Occurs when user activates a toast notification through a click or touch. Apps that are running subscribe to this event.

In order to receive activation events from toasts that are created by previous instances of the app, you also need to enumerate current toast notifications on app launch using the ToastNotificationManager class and attach an event handler to them as well.