Search code examples
azureazure-notificationhubazure-functions

notification hub using azure function


How do I send notification using hub from azure functions:

context.bindings.notification = {
   message: "Hello from " + req.body.name
};

Getting an error.

The document written:

This example sends a notification for a template registration that contains

How can I register template when using azure function?


Solution

  • First, here's a link to the notification hub bindings docs

    Here is what you need to do:

    1. From a mobile client app, register a template
      • i.e. {"aps": {"alert": "$(message)"}}
    2. Send the template payload from the azure function. You should receive the push on devices which have registered with the template
      • i.e. context.bindings.notification = { message: "this goes in the $(message) above" };