Azure / azure-notificationhubs-java-backend

Azure Notification Hubs SDK for Java
https://docs.microsoft.com/en-us/azure/notification-hubs/
Apache License 2.0
35 stars 49 forks source link

createFcmNotification - ServiceBusNotification-Format "gcm" vs "fcm", #44

Closed hangryfabian closed 3 years ago

hangryfabian commented 5 years ago

In a previous commit I see ServiceBusNotification-Format as "fcm", but in the recent ones it is "gcm". When I changed it to "fcm", the push notifications do not work (our client app is using FCM).

I'm not sure how this is handled by Azure Hub in the background, but the force over to FCM is in a few weeks, so just want to confirm "gcm" in the below function will still work after that date?

Thanks!

public static Notification createFcmNotifiation(String body) {
    Notification n = new Notification();
    n.body = body;
    n.contentType = ContentType.APPLICATION_JSON;
    n.headers.put("ServiceBusNotification-Format", "gcm");
    return n;
}
amit70 commented 5 years ago

@hangryfabian Did you get the solution for the above problem statement. Even I'm facing the same issue and being forced to FCM from google.

hangryfabian commented 5 years ago

No :(

jvbeck commented 4 years ago

The C# equivalent code sends "gcm" too - thanks to line 1794 of NotificationHubClient.cs In the SendNotificationImplAsync method we have // Convert FcmNotification into GcmNotification notification = FcmToGcmNotificationTypeCast(notification);

Problems could be caused by FcmRegistration. This sends a GcmRegistrationDescription entity in the XML whereas the C# equivalent sends an FcmRegistrationDescription entity. However, the C# code also converts any GcmRegistrationDescription objects that it receives to FcmRegistrationDescription objects so the back-end could handle this.

mpodwysocki commented 3 years ago

As noted on our ReadMe that GCM is the only valid value as FCM will throw an error as we do not fully support the FCM protocol, only the FCM-Legacy protocol via the GCM setting.