gpt4 book ai didi

使用 Cloud Functions 的 iOS 后台通知

转载 作者:行者123 更新时间:2023-11-28 23:50:12 26 4
gpt4 key购买 nike

我在应用进入后台时获取数据时遇到问题。我正在使用 Firebase Cloud 函数,我认为我在 NodeJS 中没有正确编码。我尝试了很多例子和解决方案,比如:content_available: truepriority: 'high' 但似乎没有任何效果。我必须注意:

Notifications are arriving in background and foreground but I can read data from notification in foreground but data is not fetched in background. So there is NO notifications data in background even it is displayed with sound and alert.

我认为我在数据负载方面做错了,所以这是我的 NodeJS 方法:

var message = {
token: tokenID,
notification: {
title: 'ChatApplication',
body: `${myUsername} send you a message`,

},
android: {
ttl: 3600 * 1000,
notification: {
icon: 'default',
sound: 'default',
click_action: "com.yupi.chatapplication.messaging"
},
data: {
from_user: user_id,
title: 'ChatApplication',
body: `${myUsername} send you a message`
},
},
apns: {
payload: {
aps: {
alert: {
title: 'ChatApplication',
body: `${myUsername} send you a message`
},
badge: 1,
sound: 'default',
content_available: true,
mutable_content: true,
priority: 'high'
},
},
},
};

return admin.messaging().send(message)
.then((response) => {
// Response is a message ID string.
return console.log('Successfully sent message:', response);
})
.catch((error) => {
return console.log('Error sending message:', error);
});

最佳答案

Node.js SDK 的正确字段名称应为 contentAvailablemutableContent:https://firebase.google.com/docs/reference/admin/node/admin.messaging.Aps

关于使用 Cloud Functions 的 iOS 后台通知,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52078656/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com