我使用Firebase云端函数通过Cloud Messaging向iOS设备发送通知。 sendToDevice
方法工作良好,并且返回成功承诺,但Firebase函数日志中没有任何错误或警告,但在iOS上不显示通知。如果我通过Firebase通知信息中心发送通知,该通知很有用,并且会在设备上显示通知。我不知道我在哪里可以有bug。这个错误可能在iOS应用程序端,即使它像我说的那样工作?成功sendToDevice后Firebase云消息传递不起作用
火力地堡配置:
var functions = require('firebase-functions');
var admin = require('firebase-admin');
var config = functions.config();
admin.initializeApp(functions.config().firebase);
云功能的部分:
APP.services.firebase.admin.database().ref('tokens/' + userId).once('value', function(snapshot) {
var userDevicesTokens = [];
snapshot.forEach(function(childSnapshot) {
userDevicesTokens.push(childSnapshot.key)
});
if (userDevicesTokens.length === 0) {
console.warn('No tokens for user');
return;
}
var payload = {
data: {
title: options.title,
text: options.text,
type: options.type,
}
};
APP.services.firebase.admin.messaging().sendToDevice(userDevicesTokens, payload)
.then(function(response) {
console.log("Successfully sent message:", response);
})
.catch(function(error) {
console.log("Error sending message:", error);
});
})
火力地堡云功能登录:
11: 52: 43.952 AM info newChatMessageTrigger
Successfully sent message: {
results: [{
messageId: '0:15016....'
}],
canonicalRegistrationTokenCount: 0,
failureCount: 0,
successCount: 1,
multicastId: 589....
}
11: 52: 22.760 AM outlined_flag newChatMessageTrigger
Function execution took 604 ms, finished with status: 'ok'
11: 52: 22.252 AM outlined_flag newChatMessageTrigger
Billing account not configured.External network is not accessible and quotas are severely limited.Configure billing account to remove these restrictions
11: 52: 22.252 AM outlined_flag newChatMessageTrigger
Function execution started
您是否尝试发送'notification'消息有效呢? –