Search code examples
jsonazurefirebase-cloud-messaginggoogle-chrome-appazure-notificationhub

push notification azure to FCM topics


I want to push notification messages from azure notification hub to the FCM using topics.

Example: I want to send a message to the FCM from notification hub. but this message will be directed to topics. When using postman for example, I just have to send this json:

{
    "to" : "/topics/scalability",
    "notification":{"body":"topics message sent"}
}

to https://fcm.googleapis.com/fcm/send (while providing the FCM key ofcourse).

By doing this, I am able to receive the notification on a chrome app I put in place (the app is just the same as you can find here

Now my problem is that when I send this same message on Notification hub (Azure), I don't receive it on my web app. My understanding is that the Notification Hub does not push the message (json) in its simple format, but why is that ?

Since I successfully pushed the message to FCM, isn't the FCM supposed to interpret the "to" : "/topics/scalability part ?


Solution

  • I found a workaround. I send notifications using the simple version of the Notification hub method:

    // Send the message to FCM NotificationOutcome outCome = await this.hubClient.SendGcmNativeNotificationAsync(payload). 
    

    I then receive all the messages from my chrome app