我正在设置Firebase Cloud Messaging来进行网络推送通知。目前,它只在Chrome(Windows和Android)以及Firefox(Android)中工作。但是,在预装于三星手机上的Samsung Internet Browser上却无法正常工作,而且我还没有机会在iOS上进行测试。
我已经尝试将gcm_sender_id
作为发送方ID添加到我使用的Cloud Function以及manifest.json
文件中,但没有用。以下是通知主体的设置方式。
// Create notification content
const notification = admin.messaging().Notification = {
title : 'My test Title',
body : `Lorem Ipsum Dolor`,
};
const payload = admin.messaging().Message = {
notification,
webpush:{
notification : {
vibrate: [200, 100, 200],
icon: 'https://www.goodhousekeeping.com/life/pets/g4531/cutest-dog-breeds/', //A random dog photo
fcm_options: {
link: 'https://www.youtube.com',
gcm_sender_id : '<SENDER_ID>',
},
},
},
topic: '<TOPIC>'
};
//Send notification
return admin.messaging().send(payload);
有什么办法可以让这个在三星浏览器上工作?服务工作者从v4开始就得到支持,设备已经更新到v9。值得注意的是,在即使在接收到它的设备上,当我点击它时,它也不会打开我在fcm_options
中设置的网站,也不会遵循振动模式,但它确实加载了图标。
更新:截至2020年4月,FCM与iOS Chrome和Safari完全不兼容。