and*_*ini 0 cordova firebase ionic-framework
我已经在我的 Ionic 4 应用程序中实现了 FireBaseX 来发送远程通知。
this.platform.ready().then(() => {
let platforms = this.platform.platforms();
if(platforms.includes('ios') || platforms.includes('android') || platforms.includes('mobile')){
this.firebase.getToken().then(token => {
console.log(`FIREBASE TOKEN ${token}`);
if(platforms.includes('ios')) this.firebase.grantPermission();
});
this.firebase.onMessageReceived().subscribe(data => {
console.log('FIREBASE MESSAGE', data);
});
}
});
Run Code Online (Sandbox Code Playgroud)
因此,当我在 iOS 中打开该应用程序时,它会正确请求权限。
然后我发送测试消息并且 console.log() 正确显示。
2020-02-05 17:35:38.282123-0300 Parkaz[86464:2354851] didReceiveMessage: {
"collapse_key" = "com.myapp.app";
from = 678323471xxxx;
notification = {
body = teste;
e = 1;
tag = "campaign_collapse_key_5659280550157990837";
title = teste;
};
}
Run Code Online (Sandbox Code Playgroud)
但是,如果未打开该应用程序,则什么也不会发生。通知横幅没有出现,没有徽章,没有声音......没有......
难道我做错了什么?
小智 5
您可以使用邮递员测试您的通知。
POST : https://fcm.googleapis.com/fcm/send
Run Code Online (Sandbox Code Playgroud)
标题
Content-Type:application/json
Authorization:key=AIzaXXXXXXXXXX
Run Code Online (Sandbox Code Playgroud)
身体
安卓
{
"notification": {
"title": "Your Notification Title",
"body": "This is Message",
},
"to" : FIREBASE TOKEN,
"data": {
"content-available": 1,
"foreground": false,
"clickAction": "/chat"
}
}
Run Code Online (Sandbox Code Playgroud)
IOS
{
"to" : FIREBASE TOKEN,
"data": {
"title": "Your Notification Title",
"body": "This is Message",
"content-available": 1,
"foreground": false,
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
173 次 |
| 最近记录: |