错误的Firebase Cloud Functions Typescript有效负载包含"notification.loc-args"的无效值.财产 [英] Error Firebase Cloud Functions Typescript Payload contains an invalid value for the "notification.loc-args" property
问题描述
从Firebase Cloud功能日志中接收以下针对Firebase功能的错误消息.我正在尝试使用具有动态值的本地化创建一个远程推送通知有效负载.
Receiving following error message from Firebase Cloud functions log for my Firebase Function. I am trying to create a remote push notification payload with localization which has dynamic values.
错误:消息有效负载包含"notification.loc-args"属性的无效值.值必须是字符串.
Error: Messaging payload contains an invalid value for the "notification.loc-args" property. Values must be strings.
有效负载的TypeScript代码
TypeScript code for payload
var values : String[] = [];
values.push('Johnny Appleseed');
const payload = {
notification: {
'title-loc-key': 'INVITE_PUSH_TITLE',
'loc-key': 'INVITE_PUSH_BODY',
'loc-args': values,
'type': 'Invite',
'fromName': name,
'userId': uid,
}
};
'loc-args'属性已经包含字符串数组.怎么了?
'loc-args' property already contains string array. What is wrong here?
Following sample shows how it suppose to be, based on Apple documentation
iOS的本地化参数
"GAME_PLAY_REQUEST_FORMAT" = "%@ and %@ have invited you to play Monopoly";
有效载荷
{
"aps" : {
"alert" : {
"loc-key" : "GAME_PLAY_REQUEST_FORMAT",
"loc-args" : [ "Jenna", "Frank"]
}
}
}
推荐答案
遵循FCM的有效负载解决了我的问题.
Following payload for FCM solved my problem.
const payload = {
notification: {
title: 'You have a new team request!',
body: `${name} sent team request.!`,
'title_loc_key': 'TEAM_INVITE_PUSH_TITLE',
'body_loc_key': 'TEAM_INVITE_PUSH_BODY',
'body_loc_args': `["${name}"]`
},
data: {
type: 'teamInvite',
fromName: name,
userId: uid
}
};
这篇关于错误的Firebase Cloud Functions Typescript有效负载包含"notification.loc-args"的无效值.财产的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!