Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ionic-framework/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Cordova 如何在FCMPlugin.onNotification方法2中添加代码_Cordova_Ionic Framework - Fatal编程技术网

Cordova 如何在FCMPlugin.onNotification方法2中添加代码

Cordova 如何在FCMPlugin.onNotification方法2中添加代码,cordova,ionic-framework,Cordova,Ionic Framework,我是Cordova和Ionic的新手。我目前正在从事一个项目,该项目要求使用firebase包含推送通知。因此我遵循了所有可用的turorials,并成功地包含了FCM插件 推送通知工作正常。当应用程序关闭时,会在消息栏中显示cordova默认图标。当应用程序运行时,会按预期显示警报消息 这是我在home.ts文件中使用的代码 FCMPlugin.onNotification(函数(数据){ 如果(data.wasTapped){ 警报(JSON.stringify(data.message)

我是Cordova和Ionic的新手。我目前正在从事一个项目,该项目要求使用firebase包含推送通知。因此我遵循了所有可用的turorials,并成功地包含了FCM插件

推送通知工作正常。当应用程序关闭时,会在消息栏中显示cordova默认图标。当应用程序运行时,会按预期显示警报消息

这是我在home.ts文件中使用的代码

FCMPlugin.onNotification(函数(数据){
如果(data.wasTapped){
警报(JSON.stringify(data.message));
}否则{
警报(JSON.stringify(data.message));
}
});当“函数(数据)”更改范围时,将代码包装在箭头函数中:

FCMPlugin.onNotification(
    (data)=>{
        if(data.wasTapped){
        alert( JSON.stringify(data.message) );
    } else {     
        this.navCtrl.push(UsersDetailPage);
   }
});
希望这对你有帮助。 伊曼纽尔