Search code examples
androidazurefirebase-cloud-messagingazure-notificationhub

Not able to send localized push notification from Azure Notification Hub after migrating to FCMv1 from FCM Legacy API


I am updating my production service to use FCMv1 APIs instead of FCM legacy as they have been terminated by ANH. After updating I am sending test notification from azure portal from Notification Hub -> Test Send. I am able to send normal payload like below to mobile apps and which gets delivered successfully.

{
  "message": {
    "notification": {
        "title": "message title",
        "body": "message body"
    }
  }
}

But when I am sending localized notification payload in below format I am getting error on the portal that the Notification payload is invalid.

{
  "notification": {
    "title_loc_key": "test_title",
    "title_loc_args": [
        "abcd title"
    ],
    "body_loc_key": "test_body",
    "body_loc_args": [
        "Test body text"
    ]
  }
}

enter image description here

This is the actual notification I was sending earlier in legacy API on production and was working fine. I need to send in this format only as to support multiple languages, template is stored in mobile. I just need to pass title and body args in the notification.

It is also not working when notification is pushed from code as well. I can't find any document which states if there is a different format for sending args in FCMv1. Please help me fix this issue.


Solution

  • This will resolve Notification payload is invalid issue.

    The change is {"message": {"android": {.......}}

    Example playload

    {
      "message": {
        "android": {
          "notification": {
            "body_loc_args": [
              "string"
            ],
            "title_loc_args": [
              "string"
            ],
            "title_loc_key": "string",
            "body_loc_key": "string"
          }
        }
      }
    }