push notifications not working with Azure Notification Hubs and Google Firebase Cloud Messaging migration
I have developed ionic capacitor app for push notifications with recent changes Azure Notification Hubs and Google Firebase Cloud Messaging migration all the setup according to documentation provided but i could not see my device is registerd over the azure notification hub but from the ionic app i was able get the device token and can see registration succesful need a solution for thus
Azure Notification Hubs
-
Shree Hima Bindu Maganti 1,620 Reputation points • Microsoft Vendor
2024-12-18T18:53:48.9033333+00:00 Hi Ashwitha Gudala
Welcome to the Microsoft Q&A Platform!
The issue likely lies in the integration between your Ionic app, Firebase Cloud Messaging (FCM), and Azure Notification Hubs. Even though the app generates a device token and shows successful registration, the device isn't appearing in Azure Notification Hubs.
Verify FCM Key and Sender ID in Azure.In Azure Portal, navigate to Notification Hub > Push Notification Services.
Confirm correct Firebase Server Key and Sender ID from your Firebase project.
Confirm that your app retrieves a valid FCM device token.
PushNotifications.addListener('registration', (token) => { console.log('Device Token:', token.value); });
Verify the backend sends the device token to Azure Notification Hubs using the correct payload.
{ "Platform": "gcm", "Handle": "<DEVICE_TOKEN>", "Tags": ["user:<USER_ID>"] }
Check logs in Azure Monitor for registration errors.
Manually test device registration using Postman.
API
POST https://<namespace>.servicebus.windows.net/<hub>/registrations?api-version=2015-01
Headers:
Authorization: <SAS Token>
Content-Type: application/json
{ "Platform": "gcm", "Handle": "<DEVICE_TOKEN>" }
Check app permission in AndroidManifest.xml,
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" /> <uses-permission android:name="android.permission.INTERNET" />
Verify the Firebase Server Key is valid.
Confirm FCM token validity.
Ensure the backend correctly forwards tokens to Azure.
Use the Test Send feature in Azure Notification Hub to send a notification.
https://learn.microsoft.com/en-us/azure/notification-hubs/notification-hubs-push-notification-overview
https://learn.microsoft.com/en-us/azure/notification-hubs/notification-hubs-android-push-notification-google-fcm-get-started
https://learn.microsoft.com/en-us/azure/notification-hubs/notification-hubs-push-notification-fixer
If the answer is helpful, please click "Accept Answer" and kindly upvote it. -
Shree Hima Bindu Maganti 1,620 Reputation points • Microsoft Vendor
2024-12-19T17:17:40.5266667+00:00 Following up to see if you have chance to check my previous response and help us with requested information is helpful.
-
Shree Hima Bindu Maganti 1,620 Reputation points • Microsoft Vendor
2024-12-20T16:32:54.34+00:00 Following up to see if you have chance to check my previous response and help us with requested information is helpful.
-
Gudala Ashwitha 0 Reputation points
2024-12-23T11:29:17.7466667+00:00 As the Google cloud Messaging is disabled over firebase and need to migrate to Firebase Cloud Messaging API (V1) we could see the server key as per migration documentation https://learn.microsoft.com/en-us/azure/notification-hubs/notification-hubs-gcm-to-fcm made the changes in azure notifications hub but still could receive push notifications on android. FYI already followed the above steps you mentioned, with this POST https://<namespace>.servicebus.windows.net/<hub>/registrations?api-version=2015-01 Can see registartion successful over postman but this registration is not triggered on azure hub
-
Shree Hima Bindu Maganti 1,620 Reputation points • Microsoft Vendor
2024-12-24T18:44:28.0833333+00:00 Thankyou for your response.
If the registration shows as successful in Postman but does not appear in Azure Notification Hubs,Ensure the correct FCM V1 API Key is configured in Azure Notification Hubs.
Confirm the payload includes the correct
Platform
(gcm
) and a valid FCM deviceHandle
.{ "Platform": "gcm", "Handle": "<FCM_DEVICE_TOKEN>" }
Enable Diagnostic Logs for Notification Hubs and review Azure Monitor for errors.
Ensure the correct Namespace and Notification Hub names are used in the API endpoint:
https://<namespace>.servicebus.windows.net/<hub>/registrations?api-version=2015-01
.Test the token using Firebase to ensure it is valid and active.
Use the Test Send feature in Azure Notification Hubs to verify the notification reaches the device.
https://learn.microsoft.com/en-us/azure/notification-hubs/notification-hubs-gcm-to-fcm
https://learn.microsoft.com/en-us/azure/notification-hubs/notification-hubs-gcm-to-fcm -
Gudala Ashwitha 0 Reputation points
2024-12-26T05:10:00.4766667+00:00 { "Platform": "gcm" } i have this in my payload from client side in the ionic app code, do i need to use the "Handle": "<FCM_DEVICE_TOKEN>" what is the purpose if this
-
Shree Hima Bindu Maganti 1,620 Reputation points • Microsoft Vendor
2024-12-27T07:04:19.3266667+00:00 Thankyou for your response.
Yes, the"Handle": "<FCM_DEVICE_TOKEN>"
is mandatory in the registration payload. The Handle represents the unique device token issued by Firebase Cloud Messaging (FCM), which identifies the device for push notifications.
Without the"Handle"
, Azure Notification Hubs cannot associate the registration with a device, making notifications undeliverable.{ "Platform": "gcm", "Handle": "<FCM_DEVICE_TOKEN>" }
Ensure the Ionic app retrieves the FCM device token using Firebase's
getToken()
method.import { getToken } from "firebase/messaging"; const token = await getToken(messaging, { vapidKey: "<YOUR_VAPID_KEY>" }); console.log("FCM Device Token:", token);
Include the retrieved FCM token as the
"Handle"
in the registration payload sent to Azure Notification Hubs.Test registration and notification delivery after updating the payload.
This ensures proper device registration and enables push notification delivery.
-
Gudala Ashwitha 0 Reputation points
2024-12-27T09:55:51.56+00:00 this is the payload iam using over my application
{
installationId, templates: { mytemplate: { body: bodyTemplate, tags: [uniqueTag] } }, platform: "gcm", pushChannel: deviceToken
};
already iam sending deviceToken over pushChannel, do i need to send the devicetoken again in handle key word. if Yes tried that way as well but not getting registred and push notifications are not delivered over android app -
Shree Hima Bindu Maganti 1,620 Reputation points • Microsoft Vendor
2024-12-30T17:22:10.8+00:00 Thankyou for your response.
ThepushChannel
field in your payload already represents the device token, which is equivalent to theHandle
field expected by Azure Notification Hubs for registrations. Therefore, you do not need to send the device token separately in a"Handle"
key.Ensure the payload is sent in the correct structure expected by Azure Notification Hubs.
Correct structure for a GCM/FCM registration.
{ "installationId": "<installationId>", "platform": "gcm", "pushChannel": "<deviceToken>", "templates": { "mytemplate": { "body": "<bodyTemplate>", "tags": ["<uniqueTag>"] } } }
Verify the
deviceToken
being used is valid and not expired.
You can test this token by sending a direct notification using Firebase Cloud Messaging tools.
Ensure the template body syntax in your payload is correctly configured and matches the Azure Notification Hubs format.
Enable and review diagnostic logs in Azure Notification Hubs for errors during the registration process.
If still your are facing any issue then Share any errors from the diagnostic logs or API response for further analysis. -
Shree Hima Bindu Maganti 1,620 Reputation points • Microsoft Vendor
2025-01-02T07:47:29.4266667+00:00 Following up to see if you have chance to check my previous response and help us with requested information is helpful.
-
Gudala Ashwitha 0 Reputation points
2025-01-02T10:49:46.4766667+00:00 i have Corrected structure for a GCM/FCM registration with you mentioned but not getting push notification from azure hub and also device token is not getting registred, but when i send test notification for messaging tool from firebase was getting push notifications
-
Shree Hima Bindu Maganti 1,620 Reputation points • Microsoft Vendor
2025-01-02T17:51:04.98+00:00 Thankyou for your response.
Push notifications work from Firebase but fail with Azure Notification Hubs, indicating a configuration or registration issue in Azure.
Confirm the correct Server Key (Legacy) or V1 API Key is configured in Azure.If using FCM V1 API, ensure the correct JSON configuration file is uploaded.
Ensure the payload sent to Azure matches this format{ "installationId": "<installationId>", "platform": "gcm", "pushChannel": "<deviceToken>", "templates": { "mytemplate": { "body": "<bodyTemplate>", "tags": ["<uniqueTag>"] } } }
Enable logs in Azure Portal > Monitor > Diagnostic Settings for the Notification Hub.
Review logs for registration errors or dropped tokens.
Use Firebase's
onTokenRefresh()
method to ensure you are sending a valid and updated token.Use the Test Send feature in Azure Notification Hub to send a notification to the device's tag or token.
Verify if it is delivered.
Use Azure's Registration Management REST API to confirm successful registration.Investigate any errors in the registration response.
-
Shree Hima Bindu Maganti 1,620 Reputation points • Microsoft Vendor
2025-01-06T18:13:04.6166667+00:00 Following up to see if you have chance to check my previous response and help us with requested information is helpful.
-
Shree Hima Bindu Maganti 1,620 Reputation points • Microsoft Vendor
2025-01-07T18:06:07.4366667+00:00 Following up to see if you have chance to check my previous response and help us with requested information is helpful.
-
Gudala Ashwitha 0 Reputation points
2025-01-08T05:25:56.32+00:00 Will check the Azure hub logs and will update you on this
-
Shree Hima Bindu Maganti 1,620 Reputation points • Microsoft Vendor
2025-01-10T18:04:10.7066667+00:00 Following up to see if you have chance to check my previous response and help us with requested information is helpful.
Sign in to comment