I am trying to create the following process:
An IoT device sends a message to the IoT Hub which in turn, if the message contains some value, triggers a notification to all of the registered android devices through the Notification Hub.
At first, I do not care what is the content of the message itself, and I just want to trigger a notification on every incoming message.
I have managed to set up the IoT device and connect it to the IoT hub. I have also managed to set up the Notification Hub, and connect it with the android app, in a way that when I use the "test send" in the Notification Hub, a notification is received on the android device.
In order to connect both ends (IoT Hub and Notification Hub), I tried to follow the following tutorial: https://www.developer.com/ws/android/sending-notifications-to-mobile-apps-from-azure-function-apps.html
In addition, I have added routing from the IoT Hub to the appropriate queue in the service bus.
Now, whenever the IoT device sends a message to the hub, I can see that the queue receives a message. However, I can't seem to use the queue to trigger the notification.
The ServiceHubQueueTrigger
function I have added has the following error in the portal:
Error:
Function (ServiceBusQueueTrigger1) Error: The binding type(s) 'notificationHub' are not registered. Please ensure the type is correct and the binding extension is installed.
Its function.json
looks like this:
{
"bindings": [
{
"name": "myQueueItem",
"type": "serviceBusTrigger",
"direction": "in",
"queueName": "notificationqueue",
"connection": "ServiceBusConnection",
"accessRights": "manage"
},
{
"name": "notification",
"type": "notificationHub",
"hubName": "<hub-name>",
"connection": "NotificationConnString",
"platform": "gcm",
"tagExpression": "",
"direction": "out"
}
]
}
where hub-name
is the name of the Notification Hub.
How can I trigger the notifications to the android devices through the queue?
Is there a way to trigger them directly from an IoT Hub Event Trigger
function?
Thanks!