【发布时间】:2019-12-10 05:37:45
【问题描述】:
我目前正在使用expo-server-sdk发送多个推送通知,但收到以下错误:
{ 错误:“值”必须是对象,位置 0 的“值”失败 因为 [child “to” 失败,因为 [“to” 必须是字符串,“to” 必须是 一个数组]]。
有效的推送令牌被传递给 expo.chunkPushNotifications,但是当块被传递给 expo.sendPushNotificationsAsync(chunk) 时,我收到了上面提到的错误消息:
(async () => {
for (let chunk of chunks) {
try {
let ticketChunk = await expo.sendPushNotificationsAsync(chunk);
tickets.push(...ticketChunk);
} catch (error) {
console.error(error);
}
}
})();
块的形式如下:
[ { to:
{ notificationToken: 'ExponentPushToken[some_push_token]' },
sound: 'default',
body: 'This is a test notification',
data: { withSome: 'data' } },
]
这意味着块位于对象数组的数组中:
[ [ { to: [Object],
sound: 'default',
body: 'This is a test notification',
data: [Object] },
]]
【问题讨论】:
标签: javascript reactjs react-native push-notification expo