#StackBounty: #javascript #angular #firebase #ionic-framework #cordova-plugin-fcm Firebase isn't initialised on iOS Ionic

Bounty: 50

I’ve stumbled onto a problem with my Ionic, Angular, and Firebase app.

I’ve had this problem before, but it seemed to work itself out, and now I’m having it again, and I’m wondering if anyone knows why.

I’m using Firebase FCM to store a user’s token to then send them a notification. On android this works perfectly, and on iOS it used to work..

I generated my GoogleService-Info.plist file from Firebase and put it in my main folder.

I have the following code to get the fcm token:

 getFCMToken() {
    let token;
    this.firebaseNative.getToken().then((tok) => {
        token = tok;
        if(this.platform.is('ios')) {
          this.firebaseNative.grantPermission().then((tok) => {
            return this.fcmToFirestore(token);
          }).catch(error => this.showToast("There was an error: " + error));
        } else {
          return this.fcmToFirestore(token);
    }).catch(error => {
        this.showToast("There was an error: " + error)

  fcmToFirestore(token) {
    if (!token) return;

    const devicesRef = this.afs.collection('devices')
    const docData = {
      userId: this.userData.uid,
    return devicesRef.doc(token).set(docData);

When I run the following code on an iPhone I get the toast message:

There was an error: Firebase isn’t initialised

I initialize the app in app.module.ts in the imports, which has always worked, and as I said, works fine on android.

Any idea why this doesn’t work on iOS? Thanks!

Get this bounty!!!

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.