Firebase 应用程序未激活时未调用fcm onNotification
我在Firebase 应用程序未激活时未调用fcm onNotification,firebase,firebase-cloud-messaging,angular7,ionic4,Firebase,Firebase Cloud Messaging,Angular7,Ionic4,我在fcm.onNotification中遇到问题。但在我的情况下,我会在应用程序处于后台时收到通知,正如我所期望的那样 但当我点击通知时,不会调用onNotification处理程序(应用程序正在打开,但onNotification没有响应)。当应用程序处于活动状态时,将调用onNotification处理程序 信息:-之前我在fcm插件中有问题,所以我对插件做了一些更改: 在-->/plugins/cordova plugin fcm中更新了dependecy/src/android/FCM
fcm.onNotification
中遇到问题。但在我的情况下,我会在应用程序处于后台时收到通知,正如我所期望的那样
但当我点击通知时,不会调用onNotification处理程序(应用程序正在打开,但onNotification没有响应)。当应用程序处于活动状态时,将调用onNotification处理程序
信息:-之前我在fcm插件中有问题,所以我对插件做了一些更改:
在-->/plugins/cordova plugin fcm中更新了dependecy/src/android/FCMPlugin.gradle
和-->/platforms/android/project.properties
app.component.ts中的我的代码
this.fcm.onNotification().subscribe(data => {
console.log(JSON.stringify(data));
console.log(JSON.stringify(this.fcm));
if(data.wasTapped){
console.log("Received in background data.wasTapped");
console.log(JSON.stringify(data));
} else {
console.log("Received in foreground");
};
});
使用firebase云功能发送有效负载:
dataString = '{"to": "'+token+'","notification":{"title":"Message","body":"From '+eId+'","sound":"default"},"data":{"notificationKey":"'+ key +'","goto":"messageForBidder","evid":"'+eventId+'","id":"'+id+'"},"click_action":"FCM_PLUGIN_ACTIVITY","icon":"fcm_push_icon"}';
this.fcm.onNotification().subscribe(data => {
console.log(JSON.stringify(data));
console.log(JSON.stringify(this.fcm));
if(data.wasTapped){
console.log("Received in background data.wasTapped");
console.log(JSON.stringify(data));
} else {
console.log("Received in foreground");
};
});
dataString = '{"to": "'+token+'","notification":{"title":"Message","body":"From '+eId+'","sound":"default"},"data":{"notificationKey":"'+ key +'","goto":"messageForBidder","evid":"'+eventId+'","id":"'+id+'"},"click_action":"FCM_PLUGIN_ACTIVITY","icon":"fcm_push_icon"}';