0

I am using Ionic 4 to develop android apps, now I have a problem when using @ionic-native/google-maps & @ionic-native/firebase-messaging. I cant receive push notif & triggering firebase analytics. but my google maps is normally working. also, I'm using Jscrambler for these apps

I always got this error, when calling fcm.getToken() method, which is fcm is the alias of firebase-messaging plugin. this is the error :

ERROR Error: Uncaught (in promise): Default FirebaseApp is not initialized in this process com.xxx.xxx. Make sure to call FirebaseApp.initializeApp(Context) first.
at resolvePromise (/polyfills-es2015.js:4153)
at /polyfills-es2015.js:4063
at Object.callbackFromNative (cordova.js:297)
at processMessage (cordova.js:1134)
at processMessages (cordova.js:1157)
at ZoneDelegate.invoke (/polyfills-es2015.js:3715)
at Object.onInvoke (/vendor-es2015.js:82899)
at ZoneDelegate.invoke (/polyfills-es2015.js:3714)
at Zone.run (/polyfills-es2015.js:3480)
at /polyfills-es2015.js:4211

and function to call firebase getToken on app.component.ts is here:

async initializeApp() {
  await this.platform.ready().then(() => {
    this.params.getUserData().then(userdata => {
      this.userData = userdata;
      // set fcm token when there is saved session on storage for all environment
      this.fcm.getToken().then(this.setDeviceId);
      this.fcm.onTokenRefresh().subscribe(this.setDeviceId);
      if(environment.production) {
        // init fbase analytics only on production & there is saved session on storage
        this.initFbAnalytics();
      }else{
        // subscribe to topic guest_dev when in develeopment mode
        this.fcm.subscribe("guest_dev");
      }
    });
  });
};

also my package.json file dependencies:

"dependencies": {
"@angular/animations": "^8.2.0",
"@angular/common": "^8.2.0",
"@angular/core": "^8.2.0",
"@angular/forms": "^8.2.0",
"@angular/platform-browser": "^8.2.0",
"@angular/platform-browser-dynamic": "^8.2.0",
"@angular/router": "^8.2.0",
"@ionic-native/app-rate": "^5.33.1",
"@ionic-native/camera": "^5.11.0",
"@ionic-native/clipboard": "^5.27.0",
"@ionic-native/core": "^5.11.0",
"@ionic-native/facebook": "^5.28.0",
"@ionic-native/file": "^5.27.0",
"@ionic-native/file-opener": "^5.27.0",
"@ionic-native/firebase-analytics": "^5.11.0",
"@ionic-native/firebase-messaging": "^5.11.0",
"@ionic-native/google-maps": "^5.5.0",
"@ionic-native/in-app-browser": "^5.12.0",
"@ionic-native/keyboard": "^5.29.0",
"@ionic-native/market": "^5.26.0",
"@ionic-native/mobile-accessibility": "^5.30.0",
"@ionic-native/social-sharing": "^5.11.0",
"@ionic-native/splash-screen": "^5.11.0",
"@ionic-native/sqlite": "^5.29.0",
"@ionic-native/status-bar": "^5.11.0",
"@ionic/angular": "^4.7.1",
"@types/hammerjs": "^2.0.36",
"compare-func": "^2.0.0",
"cordova-android": "9.0.0",
"cordova-browser": "6.0.0",
"cordova-clipboard": "^1.3.0",
"cordova-plugin-androidx": "^1.0.2",
"cordova-plugin-androidx-adapter": "^1.1.0",
"cordova-plugin-appsflyer-sdk": "^4.4.22",
"cordova-plugin-camera": "4.1.0",
"cordova-plugin-device": "2.0.2",
"cordova-plugin-facebook4": "^6.4.0",
"cordova-plugin-file": "^6.0.2",
"cordova-plugin-file-opener2": "^3.0.4",
"cordova-plugin-firebase-analytics": "^3.0.0",
"cordova-plugin-firebase-messaging": "^3.0.0",
"cordova-plugin-inappbrowser": "^3.1.0",
"cordova-plugin-ionic-keyboard": "^2.0.5",
"cordova-plugin-ionic-webview": "^3.0.0",
"cordova-plugin-market": "^1.2.0",
"cordova-plugin-splashscreen": "5.0.2",
"cordova-plugin-statusbar": "2.4.2",
"cordova-plugin-whitelist": "1.3.3",
"cordova-plugin-x-socialsharing": "^5.4.7",
"cordova-sqlite-storage": "^5.1.0",
"cordova-support-android-plugin": "^1.0.1",
"cordova-support-google-services": "^1.3.1",
"core-js": "^2.6.9",
"crypto-js": "^4.0.0",
"dom-to-image-more": "^2.8.0",
"es6-promise-plugin": "^4.2.2",
"hammerjs": "^2.0.8",
"ion-bottom-drawer": "^2.0.0",
"ion2-calendar": "^3.0.0-rc.0",
"ionic-long-press": "2.0.3",
"jscrambler": "^5.5.25",
"jspdf": "^1.5.3",
"moment": "^2.27.0",
"rxjs": "~6.5.2",
"text-mask-core": "^5.1.2",
"tslib": "^1.10.0",
"zone.js": "~0.9.1"
}

oh and here is my ionic info

Ionic:

   Ionic CLI                     : 6.14.0 (/usr/local/lib/node_modules/@ionic/cli)
   Ionic Framework               : @ionic/angular 4.11.13
   @angular-devkit/build-angular : 0.803.29
   @angular-devkit/schematics    : 8.3.29
   @angular/cli                  : 8.2.2
   @ionic/angular-toolkit        : 2.3.3

Cordova:

   Cordova CLI       : 10.0.0
   Cordova Platforms : not available
   Cordova Plugins   : not available

Utility:

   cordova-res                          : not installed
   native-run (update available: 1.4.0) : 1.3.0

System:

   Android SDK Tools : 26.1.1 (/home/nt/Android/Sdk)
   NodeJS            : v10.19.0 (/usr/bin/node)
   npm               : 6.14.4
   OS                : Linux 5.8
Najam Us Saqib
  • 3,190
  • 1
  • 24
  • 43

0 Answers0