How do I use a notification template with multiple custom properties in an Azure notification hub?

We follow this guide: How to: Windows Azure Notification Hubs (Android apps) for Android.

Everything works fine when structuring the notification payload, as described in the manual. I.e:

{
    "data": {
        "msg": "$(property1)"
    }
}

However, we would like to expand the template to use more than one custom property in the payload. Sort of:

{
  "data": {
    "msg": {
        "message": "$(property1)",
        "sender": "$(property2)"
    }
  }
}

where the back-end provides property values ​​through:

Dictionary<string, string> templateValues = new Dictionary<string, string>
    {
        { "property1", "Hello world" },
        { "property2", "foo" }
    };

NotificationOutcome notificationOutcome = await Hub.SendTemplateNotificationAsync(templateValues, "test");

When registering a template in the notification center from a mobile application, we get the following error:

"The supplied notification payload is invalid"

  • Can I use multiple templates in a template?
  • ( ) JSON ( )? ? (iOS, Android).

+4
2

, GCM . , :

{
   "data": {
      "message": "$(property1)",
      "sender": "$(property2)"
   }
}

Android-

intent.getStringExtra("property1");
+6

:

:

{
   "data": {
      "message": "$(property1)",
      "args": "$(property2)",
      "myargs": "$(property3)",
   }
}

:

{  
    "property1":"Jonh",    
    "property2":"1,1",
    "property3":"0",
}

:

intent.Extras.GetString("message");
intent.Extras.GetString("args");
intent.Extras.GetString("myargs");
0

All Articles