How to use WindowsPhone.Toast.LandingUri?

2 posts, 0 answers
  1. Tuomo
    Tuomo avatar
    7 posts
    Member since:
    Jun 2014

    Posted 14 Jan 2015 Link to this post

    I have a Phonegap App in which I have implemented push notifications with JavaScript SDK/REST API. When the user taps the received notification, I'm showing a local notification which contains a link(button) to a specific page (inside my app) based on the payload of the push notification. For this I'm using the on push received callback of course.

    On Android and iOS everything is working fine. It also works if the WP application is open when the push notification is received. Where I'm having problems is when the app is not running and the toast is tapped, because the notification callback is never fired. This is not unexpected, because I know that's normal behavior of WP.

    What I'm trying to do instead is to set the launch page(LandingUri) to that page. So when the user taps the toast when the app is not running, the app should open directly to that page. I'm sending the message as specified in the documentation:
    "WindowsPhone": {
        "Toast": {
            "Title": title,
            "Message": message,
            "LandingUri": uri

    When I inspect the received notification in the callback it looks like this:
        "jsonContent": {
            "wp:Text1": title,
            "wp:Text2": message,
            "wp:Param": uri
        "type": "toast"

    I have tried to set the LandingUri in multiple different ways, for example: 

    I'm using Backbone Marionette router, so that's why the url is set like this: #api/. the-page is the dynamic part that's defining where to land. The problem is, it never lands on the page I defined. Most of the time it lands on the index page and sometimes the app crashes before it even starts. No error is received, it just shuts down.

    I'm a total noob when it comes to Windows Phone, so my question is: How should I set the LandingUri in the object? Or am I doing something else wrong?

    Alternatively, is there any other way to achieve the behavior I want, which is: navigating to a specific page inside my application based on an uri received in a push notification (after the toast is tapped when the application is not running)?

    For additional information, I'm using Phonegap Build. I'm also more than happy to provide more info if needed. I would be very grateful if anyone could help me.
  2. Anton Dobrev
    Anton Dobrev avatar
    604 posts

    Posted 15 Jan 2015 Link to this post

    Hi Mika,

    Generally said the Toast notification sent to WP devices should have the following structure:

      "WindowsPhone": {
        "Toast": {
          "Title": "Some name",
          "LandingUri": "/MainPage.xaml"

    Please note the '/' symbol in front of the LandingUri path. Hybrid applications usually have only one native (XAML) phone application page (the one defined in the Task node in the WMAppManifest.xml) that is recognized by the OS as the start page of the app. As far as I understand this could not be overridden in a hybrid application. Because the tap on a Toast notification is handled on a OS level, the OS tries to find a relative Uri to a XAML view. That is why paths like '/www/mypage1.html' would not work, paths like '/MyPage1.xaml' would work if there is such page.

    In regard to your second question. The event that a toast notification has been tapped could be intercepted only in the OnNavigatedTo handler of the MainPage.xaml.cs file. Probably there would be a way to pass this event to the JavaScript shell of your app through Cordova and notify/redirect the user.

    Please, let me know if you have further questions.

    Anton Dobrev
    Everlive is now Telerik Backend Services, and is part of the Telerik Platform.
Back to Top