andrehtissot / cordova-plugin-fcm-with-dependecy-updated

Google FCM Push Notifications Cordova Plugin
MIT License
210 stars 273 forks source link

Fcm Token not received #247

Open rich25200 opened 3 years ago

rich25200 commented 3 years ago

Describe the bug I would like implement push notification with ionic 5. With android I can retrieve the FCM token but on IOS I can't. I have this error message :

FCMToken unavailable, it'll retry in one second.

Do you know what is the problem?

Package.json

"dependencies": {
    "@angular/common": "~10.0.0",
    "@angular/core": "~10.0.0",
    "@angular/forms": "~10.0.0",
    "@angular/platform-browser": "~10.0.0",
    "@angular/platform-browser-dynamic": "~10.0.0",
    "@angular/router": "~10.0.0",
    "@capacitor/android": "^2.4.5",
    "@capacitor/core": "2.4.5",
    "@capacitor/ios": "^2.4.5",
    "@ionic-native/badge": "^5.32.0",
    "@ionic-native/core": "^5.0.0",
    "@ionic-native/device": "^5.31.1",
    "@ionic-native/fingerprint-aio": "^5.30.0",
    "@ionic-native/splash-screen": "^5.0.0",
    "@ionic-native/status-bar": "^5.0.0",
    "@ionic/angular": "^5.0.0",
    "@ionic/storage": "^2.3.1",
    "cordova-plugin-badge": "^0.8.8",
    "cordova-plugin-device": "^2.0.3",
    "cordova-plugin-fcm-with-dependecy-updated": "^7.8.0",
    "cordova-plugin-fingerprint-aio": "^4.0.2",
    "moment": "^2.29.1",
    "rxjs": "~6.5.5",
    "tslib": "^2.0.0",
    "zone.js": "~0.10.3"
  },
  "devDependencies": {
    "@angular-devkit/build-angular": "~0.1000.0",
    "@angular/cli": "~10.0.5",
    "@angular/compiler": "~10.0.0",
    "@angular/compiler-cli": "~10.0.0",
    "@angular/language-service": "~10.0.0",
    "@capacitor/cli": "2.4.5",
    "@ionic/angular-toolkit": "^2.3.0",
    "@ionic/lab": "3.2.10",
    "@types/jasmine": "~3.5.0",
    "@types/jasminewd2": "~2.0.3",
    "@types/node": "^12.11.1",
    "codelyzer": "^6.0.0",
    "jasmine-core": "~3.5.0",
    "jasmine-spec-reporter": "~5.0.0",
    "karma": "~5.0.0",
    "karma-chrome-launcher": "~3.1.0",
    "karma-coverage-istanbul-reporter": "~3.0.2",
    "karma-jasmine": "~3.3.0",
    "karma-jasmine-html-reporter": "^1.5.0",
    "protractor": "~7.0.0",
    "ts-node": "~8.3.0",
    "tslint": "~6.1.0",
    "typescript": "~3.9.5"
  },
ostigley commented 3 years ago

@andrehtissot should the getToken() method return the token every time? Or only ever when the token is first generated? I am struggling to retrieve the token upon updating the app.

DavidAMcIntosh commented 3 years ago

@andrehtissot should the getToken() method return the token every time? Or only ever when the token is first generated? I am struggling to retrieve the token upon updating the app.

Did you try the onTokenRefresh()? Like so,

// refresh the FCM token this.fcm.onTokenRefresh().subscribe(token => { this.bbankSession.setFirebaseToken(token); });

DavidAMcIntosh commented 3 years ago

Describe the bug I would like implement push notification with ionic 5. With android I can retrieve the FCM token but on IOS I can't. I have this error message :

FCMToken unavailable, it'll retry in one second.

Do you know what is the problem?

Package.json

"dependencies": {
    "@angular/common": "~10.0.0",
    "@angular/core": "~10.0.0",
    "@angular/forms": "~10.0.0",
    "@angular/platform-browser": "~10.0.0",
    "@angular/platform-browser-dynamic": "~10.0.0",
    "@angular/router": "~10.0.0",
    "@capacitor/android": "^2.4.5",
    "@capacitor/core": "2.4.5",
    "@capacitor/ios": "^2.4.5",
    "@ionic-native/badge": "^5.32.0",
    "@ionic-native/core": "^5.0.0",
    "@ionic-native/device": "^5.31.1",
    "@ionic-native/fingerprint-aio": "^5.30.0",
    "@ionic-native/splash-screen": "^5.0.0",
    "@ionic-native/status-bar": "^5.0.0",
    "@ionic/angular": "^5.0.0",
    "@ionic/storage": "^2.3.1",
    "cordova-plugin-badge": "^0.8.8",
    "cordova-plugin-device": "^2.0.3",
    "cordova-plugin-fcm-with-dependecy-updated": "^7.8.0",
    "cordova-plugin-fingerprint-aio": "^4.0.2",
    "moment": "^2.29.1",
    "rxjs": "~6.5.5",
    "tslib": "^2.0.0",
    "zone.js": "~0.10.3"
  },
  "devDependencies": {
    "@angular-devkit/build-angular": "~0.1000.0",
    "@angular/cli": "~10.0.5",
    "@angular/compiler": "~10.0.0",
    "@angular/compiler-cli": "~10.0.0",
    "@angular/language-service": "~10.0.0",
    "@capacitor/cli": "2.4.5",
    "@ionic/angular-toolkit": "^2.3.0",
    "@ionic/lab": "3.2.10",
    "@types/jasmine": "~3.5.0",
    "@types/jasminewd2": "~2.0.3",
    "@types/node": "^12.11.1",
    "codelyzer": "^6.0.0",
    "jasmine-core": "~3.5.0",
    "jasmine-spec-reporter": "~5.0.0",
    "karma": "~5.0.0",
    "karma-chrome-launcher": "~3.1.0",
    "karma-coverage-istanbul-reporter": "~3.0.2",
    "karma-jasmine": "~3.3.0",
    "karma-jasmine-html-reporter": "^1.5.0",
    "protractor": "~7.0.0",
    "ts-node": "~8.3.0",
    "tslint": "~6.1.0",
    "typescript": "~3.9.5"
  },

For iOS, did you request push permission before attempting to obtain the token? This is something iOS something and not needed for Android. Like below:

// check if user granted push permission (iOS) // this always resolves to TRUE for Android devices. const doesIt = await this.fcm.requestPushPermission(); if (doesIt) { // get FCM token this.fcm.getToken().then(token => { this.bbankSession.setFirebaseToken(token); }); }

Hope that works!

digvijayLogistic commented 2 years ago

Hello @DavidAMcIntosh

I have tried to resolve issue as per your last comment, but it didn't work for me. Can you please provide any other solution if you have.

rich25200 commented 2 years ago

Hey guys,

I'm using capacitorjs and it's working like a charm 👍

https://capacitorjs.com/docs/apis/push-notifications