EddyVerbruggen / nativescript-plugin-firebase

:fire: NativeScript plugin for Firebase
https://firebase.google.com
MIT License
1.01k stars 448 forks source link

[IOS] My App crash when recieve foreground noti but background is fine (NS7/ANG10/XCODE11.7/IOS14) #1697

Open Philntps opened 3 years ago

Philntps commented 3 years ago

I Use Device token for push with Apns

I don't get any Error on VScode console Someone helpme pls...

my soucre code

firebase.registerForPushNotifications({ onPushTokenReceivedCallback: async (token: string): Promise => { this.authService.deviceToken$.next(token); await this.authService.registerNotification(); }, onMessageReceivedCallback: async (message: any): Promise => { console.log('onMessageReceivedCallback', message); alert(message); if (message.notificationTapped) { setBoolean(this.WASOPENKEY, true); this.connectivityService.loadComplete$.subscribe(async (res) => { if (res) { this.checkNotiType(message.data); } }); } }, showNotifications: true, showNotificationsWhenInForeground: true }) .then() .catch((err) => console.log('>>>> Failed to register for push'));

firebase.nativescript.json

{ "using_ios": true, "using_android": false, "analytics": true, "firestore": false, "realtimedb": false, "authentication": true, "remote_config": false, "performance_monitoring": false, "external_push_client_only": false, "messaging": false, "in_app_messaging": false, "crashlytics": true, "storage": false, "functions": false, "facebook_auth": true, "google_auth": true, "admob": false, "dynamic_links": false, "ml_kit": false }

PackageJSON

"dependencies": { "@angular-devkit/build-angular": "^0.1000.3", "@angular/animations": "10.1.3", "@angular/common": "10.1.3", "@angular/compiler": "10.1.3", "@angular/core": "10.1.3", "@angular/forms": "10.1.3", "@angular/http": "8.0.0-beta.10", "@angular/platform-browser": "10.1.3", "@angular/platform-browser-dynamic": "10.1.3", "@angular/router": "10.1.3", "@nativescript/angular": "^10.1.5", "@nativescript/background-http": "^5.0.0", "@nativescript/camera": "^5.0.0", "@nativescript/core": "^7.0.10", "@nativescript/datetimepicker": "^2.0.3", "@nativescript/firebase": "^11.0.0", "@nativescript/geolocation": "^7.0.0", "@nativescript/imagepicker": "^1.0.0", "@nativescript/schematics": "^10.1.0", "@nativescript/theme": "~2.2.1", "apollo-angular": "^1.8.0", "apollo-angular-link-http": "^1.9.0", "apollo-cache-inmemory": "^1.6.3", "apollo-client": "^2.6.4", "apollo-link": "^1.2.13", "audit": "0.0.6", "core-js": "^2.6.9", "fix": "0.0.6", "graphql": "^14.0.2", "graphql-tag": "^2.10.1", "lodash": "^4.17.20", "md5-typescript": "^1.0.5", "mwz-apple-sign-in": "file:./src/plugin/apple-sign-in", "nativescript-android-utils": "^1.0.2", "nativescript-carousel": "^7.0.1", "nativescript-checkbox-ns-7": "^22.0.0", "nativescript-fabric": "^2.0.2", "nativescript-google-maps-sdk": "^2.9.1", "nativescript-google-places-autocomplete": "^1.0.3", "nativescript-http-formdata": "^1.7.0", "nativescript-iqkeyboardmanager": "^1.5.1", "nativescript-phone": "^1.4.1", "nativescript-radiobutton": "^0.1.0", "nativescript-socket.io": "^0.11.1", "nativescript-theme-core": "^1.0.6", "nativescript-ui-sidedrawer": "^9.0.0-rc.3", "nativescript-urlhandler": "^1.3.0", "nativescript-windowed-modal": "^6.2.1", "nativescript-zxing": "^1.5.9", "reflect-metadata": "~0.1.12", "rxjs": "~6.5.5", "scriptjs": "^2.5.9", "tslib": "1.10.0", "zone.js": "~0.10.2" }, "devDependencies": { "@angular-devkit/build-angular": "~0.1000.2", "@angular/cli": "10.1.3", "@angular/compiler-cli": "10.1.3", "@nativescript/ios": "7.0.1", "@nativescript/tslint-rules": "~0.0.5", "@nativescript/types": "7.0.0", "@nativescript/webpack": "^3.0.0", "@ngtools/webpack": "^10.1.2", "@types/jasmine": "~3.5.0", "@types/jasminewd2": "~2.0.3", "@types/lodash": "^4.14.161", "@types/node": "^12.11.1", "codelyzer": "^5.1.2", "jasmine-core": "~3.5.0", "jasmine-spec-reporter": "~4.2.1", "karma": "~4.4.1", "karma-chrome-launcher": "~3.1.0", "karma-coverage-istanbul-reporter": "~2.1.0", "karma-jasmine": "~3.0.1", "karma-jasmine-html-reporter": "^1.4.2", "nativescript-dev-babel": "^0.2.1", "node-sass": "^4.7.1", "protractor": "~5.4.3", "ts-node": "~8.3.0", "ts-patch": "^1.3.0", "tslint": "~6.1.0", "typescript": "~3.9.0" }

tylerablake commented 3 years ago

I was able to get around this with the following versions:

"@nativescript/core": "~7.0.12", "@nativescript/firebase": "^11.0.0", "@nativescript/ios": "6.5.3",

Looks like something between @nativescript/ios: 6.5.3 and @nativescript/ios: 7.0.0+

saibbyweb commented 3 years ago

I was able to get around this with the following versions:

"@nativescript/core": "~7.0.12", "@nativescript/firebase": "^11.0.0", "@nativescript/ios": "6.5.3",

Looks like something between @nativescript/ios: 6.5.3 and @nativescript/ios: 7.0.0+

Tried downgrading to these versions. Didn't work for me.

tylerablake commented 3 years ago

Can you post your package.json? I've seen those versions work for multiple apps so perhaps there is another package we need to downgrade.

saibbyweb commented 3 years ago
{
  "name": "nsvue-practice",
  "main": "main.js",
  "version": "1.0.0",
  "description": "A native application built with NativeScript-Vue",
  "author": "Suhaib Khan",
  "license": "MIT",
  "scripts": {
    "pie": "$ANDROID_HOME/emulator/emulator @Pie",
    "ios": "ns run ios --emulator --no-hmr",
    "android": "ns run android --emulator --no-hmr"
  },
  "dependencies": {
    "@nativescript/core": "~7.0.12",
    "@nativescript/firebase": "^11.0.0",
    "@nativescript/geolocation": "^7.0.0",
    "@vue/devtools": "^5.3.3",
    "axios": "^0.21.0",
    "color": "^3.1.3",
    "decode-google-map-polyline": "^1.0.1",
    "nativescript-google-maps-sdk": "^2.9.1",
    "nativescript-permissions": "^1.3.11",
    "nativescript-socketio": "^3.3.1",
    "nativescript-toasty": "^3.0.0-alpha.2",
    "nativescript-vue": "^2.8.1",
    "nativescript-vue-devtools": "^1.4.0",
    "vuex": "^3.5.1"
  },
  "devDependencies": {
    "@babel/core": "^7.11.6",
    "@babel/preset-env": "^7.11.5",
    "@nativescript/android": "7.0.0",
    "@nativescript/ios": "6.5.3",
    "@nativescript/webpack": "^3.0.4",
    "babel-loader": "^8.1.0",
    "nativescript-vue-template-compiler": "^2.8.1",
    "nativescript-worker-loader": "~0.12.1",
    "sass": "^1.26.10",
    "vue-loader": "^15.9.3"
  }
}
tylerablake commented 3 years ago

Hmm the only difference I was going to suggest was angular version but I see you are using vue. Unfortunately I don't so there might be an issue with ns-vue and this plugin regarding push notifications. If there is I don't think I would be able to help, sorry! đŸ˜”

saibbyweb commented 3 years ago

Hmm the only difference I was going to suggest was angular version but I see you are using vue. Unfortunately I don't so there might be an issue with ns-vue regarding push notifications. If there is I don't think I would be able to help, sorry! đŸ˜”

I don't think it would be vue specific, there is one more issue opened regarding the same #1726

@EddyVerbruggen - If you read this, just letting you know FCM works fine (no crashes). It's only when I use external push server (node apn package) to send notifications, this crash happens on foreground.