2
votes

I have created a Notification Hub in Azure. I try to send a notification to my Android App using this programme (c#):

static void Main(string[] args)
{
  var myHub = NotificationHubClient.CreateClientFromConnectionString("my connection string", "My hub name");

  string messageJson = "{\"data\":{\"message\":\"The message\", \"title\": \"A title\"}}";

  myHub.SendFcmNativeNotificationAsync(messageJson);

  Console.WriteLine("Done! Press enter to continue");
  Console.ReadKey();
}

The notification arrives at my Android phone, but no matter how I format the Json message, the notification hub changes the title to "FCM Message".

Image showing the notification

Do you have any input to the correct way to send notifications from Azure Notification Hub?

2

2 Answers

0
votes

This is pretty late, so it may only help others who end up here, but I was having the exact same issue as you and got it figured out. In this example, "action" is a custom data field that I'm pulling out once it gets to the device, and the title and message/body are correctly displayed.

{
    "data": {
        "action": "Movement"
    },
    "notification": {
        "title": "This is a title",
        "body": "test message"
    }
}

Microsoft's example was just really terrible and confused the issue.