Current behavior:
I used Cordova-plugin-firebasex plugin 6.0.6 version in my past Ionic4 app. It was working fine. But now I have one issue with onMessageReceived() function in Ionic4 app. I upgraded my past Ionic4 app with new plugins. I will attach working package.json and not-working package.json.
I can see that any result is not happened in Xcode when I tap push notification on iOS. But for my past ionic4 app I can see Xcode function is working fully.
You can check difference between two apps using two package.json files.
https://gyazo.com/159eda4bcd269f18a7ba43defd9cdf6b
This is the Xcode function I checked.
Environment information
cordova -v : 9.0.0cordova platform lscordova plugin lssw_vers: ProductName: Mac OS X_iOS build issue:_
node -v: 10.16.3Xcode version: 10.3This is the package.json that onMessageReceived() is working fully
{
"name": "studentApp",
"version": "0.0.1",
"author": "Ionic Framework",
"homepage": "https://ionicframework.com/",
"scripts": {
"ng": "ng",
"start": "ng serve",
"build": "ng build",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e"
},
"private": true,
"dependencies": {
"@angular/common": "7.2.2",
"@angular/core": "7.2.2",
"@angular/fire": "^5.2.1",
"@angular/forms": "7.2.2",
"@angular/http": "7.2.2",
"@angular/platform-browser": "7.2.2",
"@angular/platform-browser-dynamic": "7.2.2",
"@angular/router": "7.2.2",
"@ionic-native/background-geolocation": "5.10.0",
"@ionic-native/call-number": "^5.10.0",
"@ionic-native/camera": "5.10.0",
"@ionic-native/core": "^5.0.0",
"@ionic-native/crop": "5.10.0",
"@ionic-native/date-picker": "5.10.0",
"@ionic-native/diagnostic": "5.10.0",
"@ionic-native/document-viewer": "^5.10.0",
"@ionic-native/email-composer": "5.10.0",
"@ionic-native/file": "^5.10.0",
"@ionic-native/file-opener": "^5.10.0",
"@ionic-native/file-transfer": "^5.10.0",
"@ionic-native/firebase-x": "^5.12.0",
"@ionic-native/geolocation": "5.10.0",
"@ionic-native/google-maps": "^5.0.0-beta.27",
"@ionic-native/image-picker": "^5.11.0",
"@ionic-native/image-resizer": "^5.11.0",
"@ionic-native/in-app-browser": "5.10.0",
"@ionic-native/ionic-webview": "^5.11.0",
"@ionic-native/launch-navigator": "5.10.0",
"@ionic-native/native-storage": "5.10.0",
"@ionic-native/photo-viewer": "^5.11.0",
"@ionic-native/splash-screen": "5.0.0",
"@ionic-native/status-bar": "5.0.0",
"@ionic/angular": "4.1.0",
"@mauron85/cordova-plugin-background-geolocation": "3.0.3",
"@types/google-maps": "^3.2.1",
"call-number": "1.0.1",
"com-sarriaroman-photoviewer": "^1.2.4",
"cordova-android": "^8.0.0",
"cordova-ios": "^5.0.1",
"cordova-plugin-actionsheet": "^2.3.3",
"cordova-plugin-androidx": "^1.0.2",
"cordova-plugin-androidx-adapter": "^1.1.0",
"cordova-plugin-camera": "^4.1.0",
"cordova-plugin-crop": "^0.4.0",
"cordova-plugin-datepicker": "^0.9.3",
"cordova-plugin-dialogs": "^2.0.2",
"cordova-plugin-document-viewer": "^0.9.11",
"cordova-plugin-email-composer": "^0.9.2",
"cordova-plugin-file": "^6.0.2",
"cordova-plugin-file-opener2": "^2.2.1",
"cordova-plugin-file-transfer": "^1.7.1",
"cordova-plugin-firebasex": "*",
"cordova-plugin-geolocation": "^4.0.2",
"cordova-plugin-googlemaps": "git+https://github.com/mapsplugin/cordova-plugin-googlemaps.git#multiple_maps",
"cordova-plugin-inappbrowser": "^3.1.0",
"cordova-plugin-mauron85-background-geolocation": "^3.0.1",
"cordova-plugin-nativestorage": "^2.3.2",
"cordova-plugin-telerik-imagepicker": "^2.3.3",
"cordova-serve": "^3.0.0",
"cordova.plugins.diagnostic": "^5.0.0",
"core-js": "^2.5.4",
"date-fns": "^1.30.1",
"firebase": "^6.3.3",
"info.protonet.imageresizer": "^0.1.1",
"ion-back-button-tabs": "^2.2.0",
"lodash": "^4.17.15",
"moment": "2.24.0",
"mx.ferreyra.callnumber": "0.0.2",
"rxjs": "~6.5.1",
"tslib": "^1.9.0",
"uk.co.workingedge.phonegap.plugin.launchnavigator": "^5.0.4",
"zone.js": "~0.8.29"
},
"devDependencies": {
"@angular-devkit/architect": "~0.13.8",
"@angular-devkit/build-angular": "~0.13.8",
"@angular-devkit/core": "~7.3.8",
"@angular-devkit/schematics": "~7.3.8",
"@angular/cli": "~7.3.8",
"@angular/compiler": "~7.2.2",
"@angular/compiler-cli": "~7.2.2",
"@angular/language-service": "~7.2.2",
"@ionic/angular-toolkit": "~1.5.1",
"@types/jasmine": "~2.8.8",
"@types/jasminewd2": "~2.0.3",
"@types/node": "~12.6.6",
"codelyzer": "~4.5.0",
"cordova-plugin-device": "^2.0.2",
"cordova-plugin-ionic-keyboard": "^2.1.3",
"cordova-plugin-ionic-webview": "^4.1.1",
"cordova-plugin-splashscreen": "^5.0.2",
"cordova-plugin-statusbar": "^2.4.2",
"cordova-plugin-whitelist": "^1.3.3",
"jasmine-core": "~2.99.1",
"jasmine-spec-reporter": "~4.2.1",
"karma": "~4.1.0",
"karma-chrome-launcher": "~2.2.0",
"karma-coverage-istanbul-reporter": "^2.0.6",
"karma-jasmine": "~1.1.2",
"karma-jasmine-html-reporter": "^0.2.2",
"protractor": "~5.4.0",
"ts-node": "~8.3.0",
"tslint": "~5.17.0",
"typescript": "~3.1.6"
},
"description": "An Ionic project",
"cordova": {
"plugins": {
"cordova-plugin-whitelist": {},
"cordova-plugin-statusbar": {},
"cordova-plugin-device": {},
"cordova-plugin-splashscreen": {},
"cordova-plugin-ionic-webview": {
"ANDROID_SUPPORT_ANNOTATIONS_VERSION": "27.+"
},
"cordova-plugin-ionic-keyboard": {},
"cordova-plugin-inappbrowser": {},
"mx.ferreyra.callnumber": {},
"cordova-plugin-email-composer": {
"ANDROID_SUPPORT_V4_VERSION": "27.+"
},
"cordova-plugin-geolocation": {},
"cordova-plugin-nativestorage": {},
"cordova-plugin-datepicker": {},
"cordova.plugins.diagnostic": {
"ANDROID_SUPPORT_VERSION": "28.+"
},
"cordova-plugin-camera": {
"ANDROID_SUPPORT_V4_VERSION": "27.+"
},
"cordova-plugin-crop": {},
"call-number": {},
"cordova-plugin-mauron85-background-geolocation": {
"GOOGLE_PLAY_SERVICES_VERSION": "11+",
"ANDROID_SUPPORT_LIBRARY_VERSION": "26+",
"ICON": "@mipmap/icon",
"SMALL_ICON": "@mipmap/icon",
"ACCOUNT_NAME": "@string/app_name",
"ACCOUNT_LABEL": "@string/app_name",
"ACCOUNT_TYPE": "$PACKAGE_NAME.account",
"CONTENT_AUTHORITY": "$PACKAGE_NAME",
"ALWAYS_USAGE_DESCRIPTION": "This app always requires location tracking",
"MOTION_USAGE_DESCRIPTION": "This app requires motion detection"
},
"uk.co.workingedge.phonegap.plugin.launchnavigator": {
"GOOGLE_API_KEY_FOR_ANDROID": "AIzaSyDefemPJ5EoyQ2ufccWaT1pjus5zTiEP5s",
"OKHTTP_VERSION": "3.12.0",
"LOCATION_USAGE_DESCRIPTION": "This app requires access to your location for navigation purposes"
},
"cordova-plugin-googlemaps": {
"PLAY_SERVICES_VERSION": "15.0.1",
"ANDROID_SUPPORT_V4_VERSION": "27.+"
},
"cordova-plugin-document-viewer": {},
"cordova-plugin-file-transfer": {},
"cordova-plugin-file-opener2": {
"ANDROID_SUPPORT_V4_VERSION": "27.+"
},
"cordova-plugin-file": {},
"cordova-plugin-androidx": {},
"cordova-plugin-androidx-adapter": {},
"cordova-plugin-telerik-imagepicker": {
"PHOTO_LIBRARY_USAGE_DESCRIPTION": " "
},
"info.protonet.imageresizer": {},
"com-sarriaroman-photoviewer": {},
"cordova-plugin-firebasex": {
"ANDROID_ICON_ACCENT": "#FF00FFFF",
"ANDROID_PLAY_SERVICES_TAGMANAGER_VERSION": "17.0.0",
"ANDROID_FIREBASE_CORE_VERSION": "17.0.0",
"ANDROID_FIREBASE_MESSAGING_VERSION": "19.0.0",
"ANDROID_FIREBASE_CONFIG_VERSION": "18.0.0",
"ANDROID_FIREBASE_PERF_VERSION": "18.0.0",
"ANDROID_FIREBASE_AUTH_VERSION": "18.0.0",
"ANDROID_CRASHLYTICS_VERSION": "2.10.1",
"ANDROID_CRASHLYTICS_NDK_VERSION": "2.1.0",
"ANDROID_SHORTCUTBADGER_VERSION": "1.1.22"
}
},
"platforms": [
"android",
"ios"
]
}
}
This is the package.json that onMessageReceived() is not working.
{
"name": "studentApp",
"version": "0.0.1",
"author": "Ionic Framework",
"homepage": "https://ionicframework.com/",
"scripts": {
"ng": "ng",
"start": "ng serve",
"build": "ng build",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e"
},
"private": true,
"dependencies": {
"@angular/common": "7.2.2",
"@angular/core": "7.2.2",
"@angular/fire": "^5.2.1",
"@angular/forms": "7.2.2",
"@angular/http": "7.2.2",
"@angular/platform-browser": "7.2.2",
"@angular/platform-browser-dynamic": "7.2.2",
"@angular/router": "7.2.2",
"@ionic-native/call-number": "^5.10.0",
"@ionic-native/camera": "5.10.0",
"@ionic-native/core": "^5.0.0",
"@ionic-native/crop": "5.10.0",
"@ionic-native/date-picker": "5.10.0",
"@ionic-native/device": "^5.11.0",
"@ionic-native/diagnostic": "5.10.0",
"@ionic-native/document-viewer": "^5.10.0",
"@ionic-native/email-composer": "5.10.0",
"@ionic-native/file": "^5.10.0",
"@ionic-native/file-opener": "^5.10.0",
"@ionic-native/file-path": "^5.12.0",
"@ionic-native/file-transfer": "^5.10.0",
"@ionic-native/firebase-x": "^5.12.0",
"@ionic-native/geolocation": "5.10.0",
"@ionic-native/google-maps": "^5.0.0-beta.27",
"@ionic-native/image-picker": "^5.11.0",
"@ionic-native/image-resizer": "^5.11.0",
"@ionic-native/in-app-browser": "5.10.0",
"@ionic-native/ionic-webview": "^5.11.0",
"@ionic-native/launch-navigator": "5.10.0",
"@ionic-native/local-notifications": "^5.11.0",
"@ionic-native/native-storage": "5.10.0",
"@ionic-native/network": "^5.12.0",
"@ionic-native/photo-viewer": "^5.11.0",
"@ionic-native/splash-screen": "5.0.0",
"@ionic-native/sqlite": "^5.12.0",
"@ionic-native/status-bar": "5.0.0",
"@ionic/angular": "^4.7.1",
"@ionic/storage": "^2.2.0",
"@types/google-maps": "^3.2.1",
"call-number": "1.0.1",
"com-sarriaroman-photoviewer": "^1.2.4",
"cordova-android": "^8.0.0",
"cordova-background-geolocation-lt": "git+https://github.com/transistorsoft/cordova-background-geolocation-lt.git",
"cordova-browser": "6.0.0",
"cordova-ios": "5.0.1",
"cordova-plugin-actionsheet": "2.3.3",
"cordova-plugin-androidx": "^1.0.2",
"cordova-plugin-androidx-adapter": "^1.1.0",
"cordova-plugin-background-fetch": "^5.5.0",
"cordova-plugin-badge": "^0.8.8",
"cordova-plugin-camera": "4.1.0",
"cordova-plugin-cocoalumberjack": "0.0.4",
"cordova-plugin-crop": "0.4.0",
"cordova-plugin-datepicker": "0.9.3",
"cordova-plugin-dialogs": "^2.0.2",
"cordova-plugin-document-viewer": "0.9.11",
"cordova-plugin-email-composer": "0.9.2",
"cordova-plugin-file": "6.0.2",
"cordova-plugin-file-opener2": "2.2.1",
"cordova-plugin-file-transfer": "1.7.1",
"cordova-plugin-filepath": "^1.5.6",
"cordova-plugin-firebasex": "6.0.6",
"cordova-plugin-geolocation": "^4.0.2",
"cordova-plugin-googlemaps": "git+https://github.com/mapsplugin/cordova-plugin-googlemaps.git#multiple_maps",
"cordova-plugin-inappbrowser": "3.1.0",
"cordova-plugin-local-notification": "^0.9.0-beta.2",
"cordova-plugin-nativestorage": "2.3.2",
"cordova-plugin-network-information": "^2.0.2",
"cordova-plugin-telerik-imagepicker": "2.3.3",
"cordova-serve": "^3.0.0",
"cordova-sqlite-storage": "^3.3.0",
"cordova.plugins.diagnostic": "^5.0.0",
"core-js": "^2.5.4",
"date-fns": "^1.30.1",
"firebase": "^6.3.3",
"info.protonet.imageresizer": "^0.1.1",
"ion-back-button-tabs": "^2.2.0",
"lodash": "^4.17.15",
"moment": "2.24.0",
"mx.ferreyra.callnumber": "0.0.2",
"rxjs": "~6.5.1",
"tslib": "^1.9.0",
"uk.co.workingedge.phonegap.plugin.launchnavigator": "^5.0.4",
"zone.js": "~0.8.29"
},
"devDependencies": {
"@angular-devkit/architect": "~0.13.8",
"@angular-devkit/build-angular": "~0.13.8",
"@angular-devkit/core": "~7.3.8",
"@angular-devkit/schematics": "~7.3.8",
"@angular/cli": "~7.3.8",
"@angular/compiler": "~7.2.2",
"@angular/compiler-cli": "~7.2.2",
"@angular/language-service": "~7.2.2",
"@ionic/angular-toolkit": "~1.5.1",
"@types/jasmine": "~2.8.8",
"@types/jasminewd2": "~2.0.3",
"@types/node": "~12.6.6",
"codelyzer": "~4.5.0",
"cordova-plugin-device": "^2.0.2",
"cordova-plugin-ionic-keyboard": "^2.1.3",
"cordova-plugin-ionic-webview": "^4.1.1",
"cordova-plugin-splashscreen": "^5.0.2",
"cordova-plugin-statusbar": "^2.4.2",
"cordova-plugin-whitelist": "^1.3.3",
"jasmine-core": "~2.99.1",
"jasmine-spec-reporter": "~4.2.1",
"karma": "~4.1.0",
"karma-chrome-launcher": "~2.2.0",
"karma-coverage-istanbul-reporter": "^2.0.6",
"karma-jasmine": "~1.1.2",
"karma-jasmine-html-reporter": "^0.2.2",
"protractor": "~5.4.0",
"ts-node": "~8.3.0",
"tslint": "~5.17.0",
"typescript": "~3.1.6"
},
"description": "An Ionic project",
"cordova": {
"plugins": {
"cordova-plugin-whitelist": {},
"cordova-plugin-statusbar": {},
"cordova-plugin-device": {},
"cordova-plugin-splashscreen": {},
"cordova-plugin-ionic-webview": {
"ANDROID_SUPPORT_ANNOTATIONS_VERSION": "27.+"
},
"cordova-plugin-ionic-keyboard": {},
"cordova-plugin-inappbrowser": {},
"mx.ferreyra.callnumber": {},
"cordova-plugin-email-composer": {
"ANDROID_SUPPORT_V4_VERSION": "27.+"
},
"cordova-plugin-geolocation": {},
"cordova-plugin-nativestorage": {},
"cordova-plugin-datepicker": {},
"cordova.plugins.diagnostic": {
"ANDROID_SUPPORT_VERSION": "28.+"
},
"cordova-plugin-camera": {
"ANDROID_SUPPORT_V4_VERSION": "27.+"
},
"cordova-plugin-crop": {},
"call-number": {},
"uk.co.workingedge.phonegap.plugin.launchnavigator": {
"GOOGLE_API_KEY_FOR_ANDROID": "AIzaSyDefemPJ5EoyQ2ufccWaT1pjus5zTiEP5s",
"OKHTTP_VERSION": "3.12.0",
"LOCATION_USAGE_DESCRIPTION": "This app requires access to your location for navigation purposes"
},
"cordova-plugin-googlemaps": {
"PLAY_SERVICES_VERSION": "15.0.1",
"ANDROID_SUPPORT_V4_VERSION": "27.+",
"LOCATION_WHEN_IN_USE_DESCRIPTION": "This app wants to get your location while this app runs only.",
"LOCATION_ALWAYS_USAGE_DESCRIPTION": "This app wants to get your location always, even this app runs in background."
},
"cordova-plugin-document-viewer": {},
"cordova-plugin-file-transfer": {},
"cordova-plugin-file-opener2": {
"ANDROID_SUPPORT_V4_VERSION": "27.+"
},
"cordova-plugin-file": {},
"cordova-plugin-telerik-imagepicker": {
"PHOTO_LIBRARY_USAGE_DESCRIPTION": " "
},
"cordova-background-geolocation-lt": {
"APPCOMPAT_VERSION": "27.+",
"GOOGLE_API_VERSION": "16.+",
"OKHTTP_VERSION": "3.12.+",
"EVENTBUS_VERSION": "3.0.0",
"BACKGROUND_MODE_LOCATION": "
},
"cordova-plugin-local-notification": {},
"com-sarriaroman-photoviewer": {},
"cordova-plugin-androidx": {},
"cordova-plugin-androidx-adapter": {},
"info.protonet.imageresizer": {},
"cordova-plugin-firebasex": {
"ANDROID_ICON_ACCENT": "#FF00FFFF",
"ANDROID_PLAY_SERVICES_TAGMANAGER_VERSION": "17.0.0",
"ANDROID_FIREBASE_CORE_VERSION": "17.0.0",
"ANDROID_FIREBASE_MESSAGING_VERSION": "19.0.0",
"ANDROID_FIREBASE_CONFIG_VERSION": "18.0.0",
"ANDROID_FIREBASE_PERF_VERSION": "18.0.0",
"ANDROID_FIREBASE_AUTH_VERSION": "18.0.0",
"ANDROID_CRASHLYTICS_VERSION": "2.10.1",
"ANDROID_CRASHLYTICS_NDK_VERSION": "2.1.0",
"ANDROID_SHORTCUTBADGER_VERSION": "1.1.22"
},
"cordova-plugin-network-information": {},
"cordova-sqlite-storage": {},
"cordova-plugin-filepath": {}
},
"platforms": [
"browser",
"ios",
"android"
]
}
}
If you can help me, I will be very appreciate. Thanks.
I've just published [email protected] which resolves multiple issues on iOS.
Please re-test with the version.
If you still encounter issues, please build and test with the example project to rule out causes within your project.
@dpa99c Thank you for your update. Your example project is working fully.
I updated my project with your latest version.
But in my project, there is still same issue. Do you have any idea about my project? (Please check my package.json)
Thank you.
You have many plugins in your project and I can't see the source code of your app, so I'm unable to diagnose the issue in your project.
I suggest a systematic approach to identify the cause:
onMessageReceived() success callback.onMessageReceived() is NOT called in the JS layer, open the project in Xcode and in AppDelegate+FirebasePlugin.m add breakpoints to the native code at the first line of each of these functions:didReceiveRemoteNotificationdidReceiveMessagewillPresentNotificationdidReceiveNotificationResponseHowever since the example project works for you, I'm closing this issue as it's specific to your project so not a problem with the plugin itself.
@dpa99c
Thank you for your kind message. I already debugged with xcode functions using breakpoints, as you mentioned in your message. Before that I debugged on JS level. Any result is not exist either.
But when I tap the push notification, app is opened. But xcode is not stopped on any breakpoint.
I thought it could be extensive problem of this plugin usage in productive ionic4 application.
Btw I will check more. Thanks.
I'm having what I think is the same issue on ios.
If my app is running in the foreground onMessageReceived doesn't fire and no notification appears even if I add "notification_foreground": "true" to the data.
If I put my app into the background, the notification will appear and tapping it will open the app, but onMessageReceived never fires in Javascript.
If I kill the app entirely and open a notification, onMessageReceived does seem to fire in Javascript.
In xCode, I don't see any of these showing up in the log:
didReceiveRemoteNotification
didReceiveMessage
willPresentNotification
didReceiveNotificationResponse
I have same issue
@erellsworth Could the problem be solved?
I have the same bug and it looks like a conflict with plugin cordova-plugin-local-notification. Try to remove it.
I have the same problem,
in my xcode logs i can see:
willPresentNotification:{..[some message content]..}
and
willPresentNotification: foreground notification not set.
In android it works fine and an alert() with the message content is shown from within the onMessageReceived function.
```
window.FirebasePlugin.onMessageReceived(message => {
try {
console.log('onMessageReceived');
console.dir(message);
if (message.messageType === 'notification') {
self.handleNotificationMessage(message);
} else {
self.handleDataMessage(message);
}
this.audioObj.play();
setTimeout(function() {
alert(message.title + '\n\n' + message.body);
}, 1000);
} catch (e) {
console.log('Exception in onMessageReceived callback: ' + e.message);
}
}, function(error) {
console.log('Failed receiving FirebasePlugin message', error);
});
```
managed to solve this problem?
For me the problem was a conflict with the plugin cordova-plugin-local-notifications (issue). Once i removed it, the onMessageReceived() callback started getting called.
EDIT: After upgrading the local notifications plugin from 0.9.0-beta.2 to 0.9.0-beta.3 it worked normally.
Thanks for the tip @ildarnm!
Upgrade to 0.9.0-beta.3 worked. @NilLlisterri awesome, thank you 馃檹
Most helpful comment
For me the problem was a conflict with the plugin cordova-plugin-local-notifications (issue). Once i removed it, the onMessageReceived() callback started getting called.
EDIT: After upgrading the local notifications plugin from 0.9.0-beta.2 to 0.9.0-beta.3 it worked normally.
Thanks for the tip @ildarnm!