skip to Main Content

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.

2

Answers


  1. Message format should be:

    {"message": {
    "notification": {
    "title": "Weather Update",
    "body": "Current weather conditions:nTemperature: 25°CnHumidity: 60%nWind Speed: 10 km/h"
    },
    "android": {
    "data": {
    "temperature": "25°C",
    "humidity": "60%",
    "wind_speed": "10 km/h"
    }
    }
    }
    }

    Reference: https://medium.com/@pramodyahk/migrating-to-fcm-v1-in-azure-notification-hubs-android-push-notifications-c342d76adfb2#:~:text=Please%20note%20the%20new%20notification%20body%20format%20below.

    Login or Signup to reply.
  2. 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"
          }
        }
      }
    }
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search