Hi All,
I am using this plugin with my Ionic app. I am able to receive notification and that part is working well. However once i tap on the notification, i want to redirect the user to specific page on the basis of notification but some how my onNotificationOpen() function is not getting triggered. I have written very basic code to check the functionality but this method is not getting fired. my google-service.json is already in place. Please help.
FirebasePlugin.onNotificationOpen().subscribe(
(notification: MyApp) => {
!notification.tap
? console.log(
"The user was using the app when the notification arrived..."
)
: console.log(
"The app was closed when the notification arrived..."
);
let notificationAlert = this.alertCtrl.create({
title: notification.title,
message: notification.body,
buttons: ["Ok"]
});
notificationAlert.present();
},
error => {
console.error("Error getting the notification", error);
}
);
ionic info
✔ Gathering environment info - done!
Ionic:
ionic (Ionic CLI) : 4.1.1
Ionic Framework : ionic-angular 3.9.2
@ionic/app-scripts : 2.1.4
Cordova:
cordova (Cordova CLI) : 7.1.0
Cordova Platforms : android 6.3.0
Cordova Plugins : no whitelisted plugins (19 plugins total)
System:
ios-deploy : 1.9.2
ios-sim : 5.0.13
NodeJS : v8.11.2 (/usr/local/bin/node)
npm : 6.4.1
OS : macOS Sierra
Xcode : Xcode 9.2 Build version 9C40b
cordova plugin list
cordova-plugin-camera 4.0.3 "Camera"
cordova-plugin-compat 1.2.0 "Compat"
cordova-plugin-console 1.1.0 "Console"
cordova-plugin-datepicker 0.9.3 "DatePicker"
cordova-plugin-device 1.1.7 "Device"
cordova-plugin-facebook4 1.10.1 "Facebook Connect"
cordova-plugin-firebase 1.0.5 "Google Firebase Plugin"
cordova-plugin-geolocation 2.4.3 "Geolocation"
cordova-plugin-googleplus 5.2.1 "Google SignIn"
cordova-plugin-keyboard 1.2.0 "Keyboard"
cordova-plugin-native-spinner 1.1.3 "Native Spinner"
cordova-plugin-nativestorage 2.3.2 "NativeStorage"
cordova-plugin-spinner-dialog 1.3.1 "SpinnerDialog"
cordova-plugin-splashscreen 5.0.2 "Splashscreen"
cordova-plugin-statusbar 2.4.2 "StatusBar"
cordova-plugin-telerik-imagepicker 2.2.2 "ImagePicker"
cordova-plugin-whitelist 1.3.3 "Whitelist"
cordova-plugin-x-socialsharing 5.4.1 "SocialSharing"
cordova-sqlite-storage 2.4.0 "Cordova sqlite storage plugin"
cordova.plugins.diagnostic 3.9.2 "Diagnostic"
es6-promise-plugin 4.2.2 "Promise"
ionic-plugin-keyboard 2.2.1 "Keyboard"
@akaushik79 I have reviewed the notifications code in the past but haven't done so recently. I would suggest you start trying to place a break point in the code via Android Studio. I would start with the FirebasePlugin(.java).sendNotification() method along with the FirebasePluginMessagingService(.java). onMessageReceived() method. The latter method should be called first (by Firebase) and creates the notificaition. The former method is what captures the notification's "click" (Pending Intent) and passes it to the JS bridge.
@briantq thanks for the quick revert. I would love to debug it but unfortunately i am not an expert. Would like to receive reference related to some quick fixes from the experts. I have generally noticed issues in this plugin related to different releases. If i go back to some other stable version, would it be of some help?
@akaushik79 you can try v1.0.5 as I know that version works on Android. I can confirm that v2.0.X works for notifications on iOS
@briantq i am already using v1.0.5.
@akaushik79 v1.0.5 has been released for 4 months. It's follow up release went out about a month ago, which means that v1.0.5 was the primary release for 3 months. During that time, I didn't find any related bugs, and nor did you since you opened this issue. I personally used v1.0.5 on my personal app and know it works.
All of this is pointing to a configuration issue in your project. Unfortunately, I don't have time to help debug other people's code so I think this is something you are going to have to try to solve. I can answer additional questions, but suggest that you start with the comment I made a few days ago.
Hi ,
I have now the same problem whatever the plugin version I use, but it used to work before a platform removal.
Android Studio doesn't help, netherFirebasePlugin(.java).sendNotification() or FirebasePluginMessagingService(.java). onMessageReceived() are called.
Surely a configuration issue but cant' find what to check
I had the same issue. what fixed it for me is to remove the "click_action":"FCM_PLUGIN_ACTIVITY" from the FCM payload. (it was recommended to have it in in one of the tutorials i used)
My paylod looks like this:
``javascript
{
"notification":{
"title":"Message Title",
"body": "Message Text",
"sound":"default",
"icon":"fcm_push_icon"
},
"data": {"event": EventPayload},
"to": DEVICE_TOKEN,
"priority":"high",
}
That's it!
Thanks
Closing based on comment above. Thanks @swindex
@akaushik79 if the comment above does not resolve your issue, please reopen the issue
Most helpful comment
I had the same issue. what fixed it for me is to remove the "click_action":"FCM_PLUGIN_ACTIVITY" from the FCM payload. (it was recommended to have it in in one of the tutorials i used)
My paylod looks like this:
``
javascript { "notification":{ "title":"Message Title", "body": "Message Text", "sound":"default", "icon":"fcm_push_icon" }, "data": {"event": EventPayload}, "to": DEVICE_TOKEN, "priority":"high", }