locked
Why am I getting empty messages with Custom Template? RRS feed

  • Question

  • I am trying to use a platform-independent template with Azure Notification Hub. Currently I am testing with Android and Windows.

    I am registering the template with the following:

    MyTemplate= "{\"data\": { \"message\": \"$(messageParam)\",\"args\": \"$(argsParam)\" }}";

    Template registration is all fine and when I send test notifications from Azure Portal, all the payload keys can be seen but the corresponding values are empty. The "message" value is populated on Azure Portal test page.

    If I switch to Android for FCM, everything works as expected. The problem is when I switch to "Custom Template", in the hope that I can handle both Android and Windows with the same template.

    What do I need to change so that the message values will be populated (if not already) and come though for Custom Template to devices?




    • Edited by a4sdl Tuesday, October 1, 2019 4:29 PM
    Tuesday, October 1, 2019 4:28 PM

Answers

  • I have already consulted the page you've indicated to review before I posted the question. However, I got the template just by trial and error and now it works.

    Nowhere does the document indicate the template for Android or "Custom Template" so that was left to a guesswork.

    Registered template as:

    var template = @"{""data"":{""message"":""$(message)"",""params"":""$(params)""}}";

    Sent notification as:

    msgPayload = $"{{\"message\":\"this is your message string\",\"params\":\"none\"}";

    On receiving I check for "message" and "params" keys and extract the corresponding string values for the message and params (set in example to none).


    • Marked as answer by a4sdl Saturday, October 5, 2019 11:01 PM
    • Edited by a4sdl Sunday, October 6, 2019 5:24 PM
    Saturday, October 5, 2019 11:00 PM

All replies

  • a4sdl, have you have a chance to review this doc, which discusses using templates cross platform? If not, can you please review it and let us know if you have any further questions or concerns.
    Friday, October 4, 2019 8:16 AM
  • I have already consulted the page you've indicated to review before I posted the question. However, I got the template just by trial and error and now it works.

    Nowhere does the document indicate the template for Android or "Custom Template" so that was left to a guesswork.

    Registered template as:

    var template = @"{""data"":{""message"":""$(message)"",""params"":""$(params)""}}";

    Sent notification as:

    msgPayload = $"{{\"message\":\"this is your message string\",\"params\":\"none\"}";

    On receiving I check for "message" and "params" keys and extract the corresponding string values for the message and params (set in example to none).


    • Marked as answer by a4sdl Saturday, October 5, 2019 11:01 PM
    • Edited by a4sdl Sunday, October 6, 2019 5:24 PM
    Saturday, October 5, 2019 11:00 PM