Firebase Cloud Messaging Localization Arguments Error

隐身守侯 提交于 2020-01-17 01:36:10

问题


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


回答1:


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.



来源:https://stackoverflow.com/questions/51104398/firebase-cloud-messaging-localization-arguments-error

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!