我有一个云函数,它执行此代码来向用户发送通知,我正确地收到了通知,但我想导航到一个特定的屏幕,为此我必须添加类似的点击操作。
clickAction: FLUTTER_NOTIFICATION_CLICK
我试着把这个属性放在不同的代码行中,但似乎什么都不起作用,有人能告诉我应该把它放在哪里吗?这是我的index.js文件!
const message = {
token: data['guestFcmToken'],
notification: {
title: `New message from ${data['hostName']}.`,
body: data['type'] === 'image' ? 'Photo' : data['lastMessage'],
},
data: {
showForegroundNotification: 'false',
screen: 'chat'
},
}
console.log('Sending message');
const response = await admin.messaging().send(message);
console.log(response);
您可以通过以下方式添加clickAction:'FLUTTER_NOTIFICATION_CLIK'
message = {
token: data['guestFcmToken'],
notification: {
title: `New message from ${data['hostName']}.`,
body: data['type'] === 'image' ? 'Photo' : data['lastMessage'],
},
data: {
showForegroundNotification: 'false',
screen: 'chat'
},
android: {
notification: {
clickAction: 'FLUTTER_NOTIFICATION_CLICK',
},
}
};