我的firebase函数的推送通知代码如下所示:
//fetch push tokens of all admins as well to send push notification
var tokens = []
if(pushToken !== undefined && pushToken !== '')
tokens.push(pushToken)
tokens = tokens.concat(adminPushTokens)
//push tokens need to be of customer as well as all the admins in the system. fetch admin push tokens
admin.messaging().sendToDevice(tokens, pushPayload).then(
(resp) => console.log("push notification sent")
).catch(
(err) => console.error("Error sending push notification:" + JSON.stringify(err))
)
有15-20%的时间
Error sending push notification:{"code":"app/network-timeout","message":"fcm.googleapis.com network timeout. Please try again."}
这对我们来说是一个大问题,不是一个可以接受的表现。我们如何确保提高可靠性?
1条答案
按热度按时间pkmbmrz71#
这可能是与您之前的question相同的问题:你应该返回异步
sendToDevice()
方法返回的promise。如果不返回promise,Cloud Function将不会等待异步任务完全完成。所以你应该做: