dotnet / maui

.NET MAUI is the .NET Multi-platform App UI, a framework for building native device applications spanning mobile, tablet, and desktop.
https://dot.net/maui
MIT License
22.04k stars 1.73k forks source link

.NET 8 MAUI Push Notifications (Android) using Azure Notification Hub FCM V1 protocol #23010

Open vsfeedback opened 3 months ago

vsfeedback commented 3 months ago

This issue has been moved from a ticket on Developer Community.


I have recently implemented Push Notifications using Azure Notification Hubs and Firebase messaging for .NET 8 MAUI.

And managed to successfully get this working using Legacy GCM/FCM protocol in .NET 8 MAUI (Android).

But as we now have to migrate this over to use FCM V1 due to Legacy FCM being out of support from June 2024 (!) . I have started making the migration changes to my .NET MAUI project and have run into some issues.

Changes applied:

Issue
FirebaseMessagingService.PNG

Since applying the changes, I can no longer get the overridden method OnMessageReceived(RemoteMessage p0) to trigger anymore, implemented from Firebase.Messaging.FirebaseMessagingService.

I can see the device is registered using FCM v1 protocol, if I attempt to retrieve the installation using Microsoft.Azure.NotificationHubs.NotificationHubClient after running the code shown in the DeviceInstall.PNG image.

Wondering if there are more defined/documented steps to migrate this across or if anyone can help me get this back up and working using FCM v1?

Any help would be much appreciated! Thanks!


Original Comments

Feedback Bot on 5/30/2024, 06:39 PM:

(private comment, text removed)


Original Solutions

Tommy Waite solved on 5/31/2024, 03:18 AM, 0 votes:

Finally managed to get it working. It came down to:

jkommeren commented 3 months ago

I migrated last week. I didn't have to change anything on the client side, just like the documentation suggested.

What the documentation did not mention is that the json format of data messages is different for fcm. (Data messages always trigger the method you mentioned. In background and in foreground. Regular notifications don't iirc.) that is if you're trying to send a data message. Are you?

I found out with some trial and error. I can send you the details tomorrow if you like.

samhouts commented 2 months ago

@moljac

moljac commented 2 months ago

Thanks for the feedback.

Since applying the changes, I can no longer get the overridden method OnMessageReceived(RemoteMessage p0) to trigger anymore, implemented from Firebase.Messaging.FirebaseMessagingService.

Can you get logcat from the device?

I can see the device is registered using FCM v1 protocol, if I attempt to retrieve the installation using Microsoft.Azure.NotificationHubs.NotificationHubClient after running the code shown in the DeviceInstall.PNG image.

Wondering if there are more defined/documented steps to migrate this across or if anyone can help me get this back up and working using FCM v1?

Sorry, but no. While we (I) do the bindings, but we are not the experts in APIs of almost 700 artifacts used by Android.

moljac commented 2 months ago

@jkommeren Thanks for the feedback.

I migrated last week. I didn't have to change anything on the client side, just like the documentation suggested.

What the documentation did not mention is that the json format of data messages is different for fcm. (Data messages always trigger the method you mentioned. In background and in foreground. Regular notifications don't iirc.) that is if you're trying to send a data message. Are you?

I cannot tell anything from original post.

I found out with some trial and error.

I can send you the details tomorrow if you like.

Would you be so kind and post it here please?