WIndows Phone 8.1 WNS Pass data from Toast to App

106 Views Asked by At

I'm having some issues implementing Push Notifications in my Windows Phone 8.1 app. I've retrieved a Channel URI as such:

var channel = await PushNotificationChannelManager.CreatePushNotificationChannelForApplicationAsync();
return channel.Uri;

I am able to send Toast notifications to my device, however I am unable to access any information about this push notification, when I open the app. Usually there would be some sort of 'Launch arguments' or something similar, but I've found nothing that provides anything when I launch via a tap on the Toast.

I've read a few posts where people suggest I override App.OnLaunched(LaunchActivatedEventArgs), but this doesn't work either. There is no change in the parameter value between when I launch the app manually, and when I launch it via tapping on a Push Notification.

Am I missing some obvious argument here?

To clarify: I can see my Push Notification being received on the device itself, but I cannot pass data from the push notification into my App (upon tapping the notification which launches my app).

The XML content I post to send a push notification is as following:

string xml = $@"
<toast>
    <visual>
        <binding template=""ToastText02"">
            <text id=""1"">{pushNotification.Title}</text>
            <text id=""2"">{pushNotification.Message}</text>
        </binding>
    </visual>
</toast>";
1

There are 1 best solutions below

1
On BEST ANSWER

Could you try to add a "launch" parameter into the tag? You should see it inside LaunchActivatedEventArgs.Arguments then:

string xml = $@"
    <toast launch=""ActivatedByToast"">
        <visual>
            <binding template=""ToastText02"">
                <text id=""1"">{pushNotification.Title}</text>
                <text id=""2"">{pushNotification.Message}</text>
            </binding>
        </visual>
    </toast>";