Support of Azure Notification Hubs’ Firebase Cloud Messaging legacy API will be retired by 1 July 2024

Vijay Pratap Singh 21 Reputation points
2024-04-24T05:33:45.3866667+00:00

I am using ASP.NET Core Web API to send push notifications to Android and iOS devices using the method given below. I am not using any API endpoint directly. Should I change anything in this?

 string jsonPayLoad = string.Empty;
                            //if (hubNotification.DeviceType.ToLower().Equals("ios.") || hubNotification.DeviceType.ToLower().Contains("iphone") || hubNotification.DeviceType.ToLower().Contains("ipad"))// For sending to iOS
                            //{

                            NotificationOutcome outcome;
                            if (hubNotification.DeviceType.ToLower().Contains("android"))
                            {
                             //   var registeredNewDevice = hub.CreateGcmNativeRegistrationAsync(hubNotification.DeviceId.Replace("-", ""), new[] { hubNotification.ToUserEmail }).Result;
                                var registeredNewDevice = hub.CreateGcmNativeRegistrationAsync(hubNotification.DeviceId, new[] { hubNotification.ToUserEmail }).Result;
                                //Silent Notification
                                jsonPayLoad = "{ \"data\": " +
                                "{" +
                                 "\"content-available\":" + 1 + "," +
                                "\"sound\":\"\"," +
                                 "\"notificationType\": \"" + hubNotification.NotificationType + "\"," +
                                "\"type\":\"sendfriend\"}}";                             

                                outcome = hub.SendGcmNativeNotificationAsync(jsonPayLoad, hubNotification.ToUserEmail).Result;

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.
325 questions
ASP.NET Core
ASP.NET Core
A set of technologies in the .NET Framework for building web applications and XML web services.
4,614 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. SnehaAgrawal-MSFT 21,766 Reputation points
    2024-04-30T04:35:52.8833333+00:00

    @Vijay Pratap Singh Apologies for late response! I discussed your scenario internally with PG and you would need to use FCM v1. The code shows that you are still using GCM. The JSON payload needs to be updated to FCM v1.

    Refer- Azure Notification Hubs and the Google Firebase Cloud Messaging (FCM) migration using SDKs | Microsoft Learn

    Please let us know if further query.

    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.