更新时间:2023-02-26 21:13:33
是的,有.您必须直接设置推送通知负载的 aps
字典并使用 loc-key
和可选的 loc-args
和 action-loc-key
参数.在第一个参数中,您传递已在应用程序包的 Localizable.strings
文件中本地化的消息的本地化键.在第二个参数中,您可以传递一个数组,该数组将被替换为本地化消息中的字符串占位符.第三个参数将用作默认操作的名称(滑动到……")
Yes, there is. You have to set the aps
dictionary of the push notification payload directly and use the loc-key
and optionally the loc-args
and action-loc-key
parameters. In the first parameter you pass the localization key of the message that you have localized in your Localizable.strings
file in your application bundle. In the second argument you can pass an array that will be substituted to the string placeholders in the localized message. The third argument will be used as the name of the default action ("slide to …")
例如,您在 Localizable.stings
文件中定义以下键:
For example you define in your Localizable.stings
file the following key:
"msg" = "%@ wants to send you a message";
"rsp" = "respond";
在云代码中,您可以按如下方式构建推送负载:
And in cloud code you construct your push payload as follows:
var payload =
"data":{
"aps":{
"alert":{
"loc-key":"msg",
"loc-args":["John"],
"action-loc-key":"rsp"
},
}
};
// set at least the 'where' key of the payload
Parse.Push.send(payload);
此代码应向您显示John 想向您发送消息",已本地化为用户的当前区域设置,默认操作将是滑动响应..."
This code should show you "John wants to send you a message", localized to the current locale of the user and the default action would be "slide to respond…"