Unable to Receive Push Notifications in .NET MAUI After Migrating from Xamarin with Azure Notification Hub and Firebase FCM

Omkar Pawar 100 Reputation points
2025-02-02T17:38:11.7+00:00

Hello

I am in the process of migrating an application from Xamarin to .NET MAUI, and I am using .NET 8 for MAUI development. Previously, I used Azure Notification Hub in combination with Firebase FCM v1 token to send push notifications.

Everything was working fine with Xamarin, but after migrating to .NET MAUI, push notifications are no longer being received on the Android device. Here is a breakdown of what I have done so far:

  • I am using the plugin Plugin.Firebase.CloudMessaging (Version 3.1.2) to generate the FCM v1 token.
  • I am able to register the device and send a push notification via WebAPI using Azure Notification Hub, which appears to be successful (no errors).
  • However, when I test the push notification from the Azure portal, it shows a "successful" message, but the notification doesn’t appear on the Android device.
  • If I use the same FCM v1 token and send a push notification directly from the Firebase console, it works and the notification is received on the Android device.

I have tried troubleshooting, but I am not sure why the notification works from Firebase directly but not through Azure Notification Hub in the context of .NET MAUI.

Has anyone encountered this issue or can offer guidance on how to resolve it?

Thanks in advance!

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.
340 questions
.NET MAUI
.NET MAUI
A Microsoft open-source framework for building native device applications spanning mobile, tablet, and desktop.
3,889 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Bhargavi Naragani 410 Reputation points Microsoft Vendor
    2025-02-04T05:36:44.5566667+00:00

    Hi @Omkar Pawar,
    Welcome to the Microsoft Q&A Platform!

    Your app is working fine with Firebase, and there's no problem with Firebase itself. However, it seems like the issue is how Azure Notification Hubs is sending messages to your.NET MAUI app. Specifically, the way Azure handles tokens from Firebase (called FCM v1 tokens) might be different in a.NET MAUI environment compared to how it worked in older Xamarin projects.

    1. Ensure your app is sending the correct token to Azure Notification Hub during registration. Log the token that your app generates and compare it with the token which is working as a result of the message from Firebase Console, they should be same.
    2. Ensure you have setup Azure Notification Hub correctly to make use of latest version of the Firebase API. (FCM v1 and not the previous version).
    3. Make sure that you have successfully added the appropriate information from your Firebase Service Account to Azure Notification Hub. That is, it must contain all the required permissions.
    4. .NET MAUI does push notifications in a different manner than older Xamarin apps do. It utilizes IFirebaseMessagingService.
      Ensure you have implemented:
         CrossFirebaseCloudMessaging.Current.OnNotificationReceived += (s, p) =>
         {
             // Handle the notification received event
             Debug.WriteLine("Notification Received: " + p.Data);
         };
      
    5. Ensure your AndroidManifest.xml file contains all of the permissions that your app requires to receive push notifications:
         <uses-permission android:name="android.permission.POST_NOTIFICATIONS"/>
      
    6. Instead of a notification payload, try sending a data-only message via Azure to see if it reaches the app:
         {
           "data": {
             "title": "Test",
             "body": "This is a test notification"
           }
         }
      
    7. Enable detailed logging in Azure Notification Hub. This will help you see exactly what's happening when Azure tries to send a message to your device, which can be very helpful for troubleshooting.

    Overview:
    https://learn.microsoft.com/en-us/samples/dotnet/maui-samples/webservices-pushnotifications/
    https://learn.microsoft.com/en-us/dotnet/maui/migration/push-notifications?view=net-maui-9.0

    Hope the above provided information help in better understanding and help you resolve the issue, if you have any further concerns or queries, please feel free to reach out to us.
    If the answer is helpful, please click Accept Answer and kindly upvote it so that other people who faces similar issue may get benefitted from it.

    1 person found this answer helpful.
    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.