Janosch Hübner
Janosch Hübner

Reputation: 1694

Firebase Cloud Messaging Localization Arguments Error

I am providing the following Payload to admin.messaging().sendToDevice(fcmToken, message);

var message = {
    notification: {
      title_loc_key: "NOTIFICATION_TITLE",
      body_loc_key: "NOTIFICATION_BODY",
      body_loc_args: ["Body Arg"],
      sound: 'default'
    }
};

However this generates the following error:

Messaging payload contains an invalid value for the "notification.body_loc_args" property. Values must be strings.

I don't see how "Body Arg" is not a string. I also tried specifying a string but this also did not work...

Any idea what the problem could be?

Thanks

Upvotes: 0

Views: 1103

Answers (1)

Jen Person
Jen Person

Reputation: 7546

I'm not sure what version of the Admin SDK is being used, but if the code is on the latest, then only title and body go in the notification object. Other values go under the payload key. Here's an example in the guide. Here is the API reference. Your message variable should look somewhat like this:

var message = {
  apns: {
    payload: {
      aps: {
        alert: {
          title_loc_key: "NOTIFICATION_TITLE",
          body_loc_key: "NOTIFICATION_BODY",
          body_loc_args: ["Body Arg"],
          sound: 'default'
        }
      }
    }
  }
};

If the code doesn't use the latest version of the Admin SDK, I recommend updating.

Upvotes: 2

Related Questions