【发布时间】:2020-10-18 15:58:07
【问题描述】:
我在两个平台上都遇到了 FCM 插件 (https://ionicframework.com/docs/native/fcm) 的问题,他的问题是我无法在应用关闭/杀死时处理通知,onNotification () 方法没有被触发(它在后台和前台都能正常工作)
this.fcm.onNotification().subscribe((payload) => {
if (payload.wasTapped) {
console.log('Notification received in background');
} else {
console.log('Notification received in foreground');
}
console.log('Notification payload: ',payload);
});
通知主体在后台和前台工作正常(两个平台):
{
"to" : <device-key>,
"collapse_key" : "app-key",
"notification" : {
"body" : "body",
"title": "title"
},
"data" : {"parameter":"1"},
"android": {
"notification": {
"click_action": "FCM_PLUGIN_ACTIVITY"
}
}
}
IOS 环境的离子信息输出:
Ionic:
Ionic CLI : 6.11.10 (/usr/local/lib/node_modules/@ionic/cli)
Ionic Framework : @ionic/angular 5.3.3
@angular-devkit/build-angular : 0.901.12
@angular-devkit/schematics : 9.1.12
@angular/cli : 9.1.12
@ionic/angular-toolkit : 2.3.3
Cordova:
Cordova CLI : 10.0.0
Cordova Platforms : ios 6.1.1
Cordova Plugins : cordova-plugin-fcm-with-dependecy-updated: ^7.3.1
System:
ios-sim : 8.0.2
NodeJS : v14.13.0 (/usr/local/Cellar/node/14.13.0/bin/node)
npm : 6.14.8
OS : macOS Catalina
Xcode : Xcode 12.0.1 Build version 12A7300
【问题讨论】:
-
Ionic 5 + Angular 仍然无法正常工作,您找到解决方案了吗?谢谢
-
不幸的是我没有 -.-
标签: ionic-framework notifications ionic5 cordova-plugin-fcm