push notifications not working with Azure Notification Hubs and Google Firebase Cloud Messaging migration

Ashwitha Gudala 0 Reputation points
2024-12-17T14:06:53.8466667+00:00

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
Azure Notification Hubs
An Azure service that is used to send push notifications to all major platforms from the cloud or on-premises environments.
334 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Shree Hima Bindu Maganti 1,585 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.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.