I use FirebaseX to receive notification in my application. I correctly receive notification in the background. But when the app is in the foreground, nothing happens...
I have searched for this problem, but nothing works for me. I have try to had the following data in the data content (when server call url to send notification) [notification_foreground] => true [tap] => true
Here is my plugin list :
cordova-plugin-androidx-adapter 1.1.0 "cordova-plugin-androidx-adapter"
cordova-plugin-app-version 0.1.9 "AppVersion"
cordova-plugin-badge 0.8.8 "Badge"
cordova-plugin-device 2.0.3 "Device"
cordova-plugin-dialogs 2.0.2 "Notification"
cordova-plugin-fcm-with-dependecy-updated 3.0.0 "Cordova FCM Push Plugin"
cordova-plugin-file 6.0.2 "File"
cordova-plugin-firebasex 5.0.0 "Google Firebase Plugin"
cordova-plugin-ionic-keyboard 2.2.0 "cordova-plugin-ionic-keyboard"
cordova-plugin-ionic-webview 4.1.1 "cordova-plugin-ionic-webview"
cordova-plugin-local-notification 0.9.0-beta.2 "LocalNotification"
cordova-plugin-speechrecognition 1.1.2 "Speech Recognition"
cordova-plugin-splashscreen 5.0.3 "Splashscreen"
cordova-plugin-statusbar 2.4.3 "StatusBar"
cordova-plugin-whitelist 1.3.4 "Whitelist"
ionic info:
Ionic:
Ionic CLI : 5.2.8
Ionic Framework : @ionic/angular 4.9.0
@angular-devkit/build-angular : 0.13.9
@angular-devkit/schematics : 7.3.9
@angular/cli : 7.3.9
@ionic/angular-toolkit : 1.5.1
Cordova:
Cordova CLI : 9.0.0 (cordova-lib@9.0.1)
Cordova Platforms : android 8.0.0
Cordova Plugins : cordova-plugin-ionic-keyboard 2.2.0, cordova-plugin-ionic-webview 4.1.1, (and 23 other plugins)
Utility:
cordova-res : 0.5.1
native-run : 0.2.7
System:
NodeJS : v10.16.0
npm : 6.10.1
OS : Windows 10
the code to subscribre to the message...
this.firebase.onMessageReceived().subscribe(notification => {
console.log('NOTIFICATION !!!!');
console.log(notification);
alert( JSON.stringify(notification) );
if (notification['tap']) {
this.navCtrl.navigateRoot('/test');
} else {
alert( JSON.stringify(notification) );
}
});
When the app is in the background, I receive the notification and when I tap on it, I have the alert message and console log.
But when the app is in the foreground, nothing is displayed.
Thanks for your help.
With --prod it seem to work without doing nothing else... it's in debug mode that is not working