iOS的Firebase云消息本地化参数?
我正在尝试使用FCM为iOS编写本地化推送通知。我想不出这封信的正确格式。这是我现在格式化它的方式:iOS的Firebase云消息本地化参数?,ios,firebase,firebase-cloud-messaging,apple-push-notifications,google-cloud-functions,Ios,Firebase,Firebase Cloud Messaging,Apple Push Notifications,Google Cloud Functions,我正在尝试使用FCM为iOS编写本地化推送通知。我想不出这封信的正确格式。这是我现在格式化它的方式: async function sendLocationLostNotification(notificationToken: string, newOwner: string, locationName: string) { const message = { name: "Location Lost Notification", token: notif
async function sendLocationLostNotification(notificationToken: string, newOwner: string, locationName: string) {
const message = {
name: "Location Lost Notification",
token: notificationToken,
apns: {
payload: {
aps: {
alert: {
loc_key: "location-lost-notification-body",
loc_args: [newOwner, locationName]
},
sound: "default"
}
}
}
};
return await admin.messaging().send(message)
}
这给了我以下错误:
src/index.ts:109:41 - error TS2345: Argument of type '{ name: string; token: string; apns: { payload: { aps: { alert: { loc_key: string; loc_args: string[]; }; sound: string; }; }; }; }' is not assignable to parameter of type 'Message'.
Type '{ name: string; token: string; apns: { payload: { aps: { alert: { loc_key: string; loc_args: string[]; }; sound: string; }; }; }; }' is not assignable to type 'TokenMessage'.
Types of property 'apns' are incompatible.
Type '{ payload: { aps: { alert: { loc_key: string; loc_args: string[]; }; sound: string; }; }; }' is not assignable to type 'ApnsConfig'.
Types of property 'payload' are incompatible.
Type '{ aps: { alert: { loc_key: string; loc_args: string[]; }; sound: string; }; }' is not assignable to type 'ApnsPayload'.
Types of property 'aps' are incompatible.
Type '{ alert: { loc_key: string; loc_args: string[]; }; sound: string; }' is not assignable to type 'Aps'.
Types of property 'alert' are incompatible.
Type '{ loc_key: string; loc_args: string[]; }' is not assignable to type 'string | ApsAlert | undefined'.
Type '{ loc_key: string; loc_args: string[]; }' has no properties in common with type 'ApsAlert'.
109 return await admin.messaging().send(message)
我已经阅读了从中引用的正确有效负载格式。也看到了类似的问题,但Jen Person建议的格式给了我和现在面临的相同的错误。我能够使其静音的唯一方法是向警报对象添加标题
或正文
,但这会覆盖loc键。看来这些钥匙是强制性的。此外,我还尝试过分别使用body\u loc\u key
和title\u loc\u key
,并且一次全部使用,但没有成功
这里可能有什么问题?结果是
ApsAlert
使用了locKey
和locArgs