Azure Notification Hubs Push Notification Id is blank

Chris Job 1 Reputation point

I am going thru Microsoft's documentation for sending a push notification. I have the notificationhub up and running, a basic android app. I can successful send a message via the portal to the app.
I am trying to send a message to the app via the code below but notification id is
always blank

Snippet of my code

namespace PushToApp
class Program

    static async Task Main()
        var config = new ConfigurationBuilder()
            .AddJsonFile("config.json", optional: false)

        var nhClient = NotificationHubClient.CreateClientFromConnectionString(config["PrimaryConnectionString"], config["HubName"], true);

        var message = "This a test";

        var fcmDeviceId = Guid.NewGuid().ToString();

        var fcmInstallation = new Installation
            InstallationId = "fake-fcm-install-id",
            Platform = NotificationPlatform.Fcm,
            PushChannel = fcmDeviceId, 
            PushChannelExpired = false,
            Tags = new[] { "fcm" }

        await nhClient.CreateOrUpdateInstallationAsync(fcmInstallation);
        await SendNotificationAsync(nhClient, message);

    private static async Task SendNotificationAsync(NotificationHubClient nhClient, string message)

        var alert = "{\"aps\":{\"alert\":\"" + message + "\",\"sound\":\"default\"}}";

        var outcomeFcm = await nhClient.SendFcmNativeNotificationAsync(alert);

        Console.WriteLine("result: " + outcomeFcm.Results.Count());
        Console.WriteLine("state: " + outcomeFcm.State);
        Console.WriteLine("Tracking Id: " + outcomeFcm.TrackingId);
        Console.WriteLine("notification Id: " + outcomeFcm.NotificationId);

 } //class

} //namespace


Count: 3
Tracking Id:a8b19b49-9857-401f-a1b1-af7dcb896e8b
notification Id:

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.
181 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. ptzedakis com 1 Reputation point

    Hi ChrisJob-0463,
    First of all, I think you use the wrong payload for sending a push notification to Android. The json payload you used in code line 31 is for Apple Push Notification service (APNs), not FCM.

    I suggest you use the following payload and see what happens:

    "title":"Notification Hub Test Notification",
    "body":"This is a sample notification delivered by Azure Notification Hubs."

    For more info:

    Hope it helps.