android - ionic 3 fcm.onNotification() 错误:找不到类
问题描述
当我执行 this.fcm.onNotification() 时出现错误“找不到类”。
我用的是安卓设备。
我遵循此文档https://ionicframework.com/docs/native/fcm/,但我不知道如何解决此问题
离子信息
cli packages: (/usr/local/lib/node_modules)
@ionic/cli-utils : 1.19.2
ionic (Ionic CLI) : 3.20.0
global packages:
cordova (Cordova CLI) : 8.0.0
local packages:
@ionic/app-scripts : 3.1.9
Cordova Platforms : android 6.4.0 ios 4.5.4
Ionic Framework : ionic-angular 3.9.2
System:
ios-deploy : 1.9.2
Node : v10.6.0
npm : 6.1.0
OS : macOS High Sierra
Xcode : Xcode 9.4 Build version 9F1027a
Environment Variables:
ANDROID_HOME : not set
Misc:
backend : pro
app.component.ts
constructor(private fcm: FCM) {
this.platform.ready().then(() => {
alert('platform ready...');
this.fcm.subscribeToTopic('marketing');
this.fcm.getToken().then(token => {
alert(token);
// backend.registerToken(token);
});
this.fcm.onNotification().subscribe(data => {
if (data.wasTapped) {
alert("Received in background");
} else {
alert("Received in foreground");
}
},
error => alert(error)
);
this.fcm.onTokenRefresh().subscribe(token => {
alert(token);
// backend.registerToken(token);
});
});
插件版本
cordova-plugin-fcm 2.1.2 "FCMPlugin"
解决方案
推荐阅读
- vue.js - vuejs vue-cli 如何使用 console.log 而不会出现任何错误
- node.js - Get stdout and stderr of a nodejs application running in background as process
- python - 如何使用python从特定关键字中提取有限的数据行
- r - Submit R jobs in slurm on a cluster server and saving objects in a different directory than the slurm working directory
- javascript - Version JS files in react
- php - 如何关联来自不同工厂的数据?
- sql - Running "distinct on" across all unique thresholds in a postgres table
- python-3.x - ElementNotVisibleException Error with xpath selenium python
- mysql - How to convert string 'mm-yyyy' column to timestamp in MYSQL?
- redux - 为什么会出现此错误 TypeError: Cannot read property 'type' of undefined