0

I am working on a Windows Phone 8.1 silverlight app, raw notifications handling.

The App when receives notifications in foreground, has to cancel the notification and create a new notification using ToastNotificationManager.CreateToastNotifier().

It also has a backgroundtask to work on the raw notifications received in background, which converts the raw notifications received to toast notification using ToastNotificationManager.CreateToastNotifier().

Also some action A needs to be performed on clicking of this notification.

The issue arises when the App receives the notification when in foreground, but the notification is clicked after suspending the application. Since the registered activated event of such type of notification is not in the background task (because the notification was formed in the foreground logic), no action A is performed on clicking of the notification.

This seems to a limitation, for WP8.1 silverlight apps. Can somebody suggest a solution for this issue??

Tulika
  • 625
  • 1
  • 8
  • 23
  • By RAW Notification did you actually mean RAW or Toast notification (this is 2 different type of notification in WP. – ad1Dima Aug 16 '16 at 06:10
  • I meant raw notifications only, since in WP8.1 backgroundtasks are triggered only by raw notifications. – Tulika Aug 16 '16 at 06:11

1 Answers1

2

If you need to do some action after tap on Toast you should add wp:Param to your Toast with deep url and handle in you app. Toast will be look like

<wp:Notification xmlns:wp=\"WPNotification\">
    <wp:Toast>
        <wp:Text1>You title</wp:Text1>
        <wp:Text2>Your subtitle</wp:Text2>" +
        <!-- You can add any parameter you want in deep url -->
        <wp:Param>/Page2.xaml?NavigatedFrom=Toast Notification</wp:Param>
    </wp:Toast>
</wp:Notification>

When you tap on toast it by default will open Page2.xaml of your app and pass uri parameters to it

ad1Dima
  • 3,185
  • 2
  • 26
  • 37
  • Ok, but why can`t navigating to Page2 be done from Activated event? Is it a limitation for WP8.1 silverlight apps? – Tulika Aug 16 '16 at 06:24
  • @Tulika I don't understand your goal – ad1Dima Aug 16 '16 at 06:30
  • Currently the logic for doing action A is done from the activated event for the toastnotification either from Foreground or background task. The alternative you suggested requires me to add the param in the toast xml, my question is can we not achieve the action A from toast`s activated event only? – Tulika Aug 16 '16 at 06:34
  • @Tulika did you try this event? https://msdn.microsoft.com/en-us/library/windows/apps/xaml/windows.ui.notifications.toastnotification.activated.aspx – ad1Dima Aug 16 '16 at 06:41
  • Yes I am using this activated event only. But as mentioned in the question issue is only for one scenario, when the toast notification is shown from foreground hence the activated event that was bind to the toast was mentioned in FG logic, but the toast is clicked on when app is in BG. – Tulika Aug 16 '16 at 06:46
  • @Tulika And when are you subscribing for this event? MSDN says you should do it in Application_Activated or earlier. – ad1Dima Aug 16 '16 at 06:50
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/121024/discussion-between-tulika-and-ad1dima). – Tulika Aug 16 '16 at 06:50