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

Google FCM Push Notifications Cordova Plugin
MIT License
208 stars 277 forks source link

Cannot read properties ( 'getToken') at /cordova-plugin-fcm-with-dependecy-updated/ionic/ngx #286

Open ash737 opened 2 years ago

ash737 commented 2 years ago

Hi, I'm using ionic 4 with fcm cordova, My issue is user token work perfect in emulator but, in android device its not given me the token.

My cordova plugin list

com-sarriaroman-photoviewer 1.2.4 "PhotoViewer"
com.moust.cordova.videoplayer 1.0.1 "Video Player"
cordova-plugin-add-swift-support 2.0.2 "AddSwiftSupport"
cordova-plugin-android-permissions 1.1.0 "Permissions"
cordova-plugin-androidx 3.0.0 "cordova-plugin-androidx"
cordova-plugin-androidx-adapter 1.1.1 "cordova-plugin-androidx-adapter"
cordova-plugin-app-version 0.1.9 "AppVersion"
cordova-plugin-apprate 1.5.0 "AppRate"
cordova-plugin-badge 0.8.8 "Badge"
cordova-plugin-camera 4.1.0 "Camera"
cordova-plugin-device 2.0.2 "Device"
cordova-plugin-dialogs 2.0.2 "Notification"
cordova-plugin-fcm-with-dependecy-updated 7.0.10 "Cordova FCM Push Plugin"
cordova-plugin-file 6.0.2 "File"
cordova-plugin-file-transfer 1.7.1 "File Transfer"
cordova-plugin-filepath 1.6.0 "cordova-plugin-filepath"
cordova-plugin-geolocation 4.0.2 "Geolocation"
cordova-plugin-googleplus 8.5.2 "Google SignIn"
cordova-plugin-hkvideoplayer 1.0.12 "hkvideoplayer"
cordova-plugin-ionic-keyboard 2.2.0 "cordova-plugin-ionic-keyboard"
cordova-plugin-ionic-webview 4.2.1 "cordova-plugin-ionic-webview"
cordova-plugin-nativegeocoder 3.4.1 "NativeGeocoder"
cordova-plugin-nativestorage 2.3.2 "NativeStorage"
cordova-plugin-request-location-accuracy 2.3.0 "Request Location Accuracy"
cordova-plugin-splashscreen 5.0.2 "Splashscreen"
cordova-plugin-statusbar 2.4.2 "StatusBar"
cordova-plugin-whitelist 1.3.3 "Whitelist"
cordova-plugin-x-socialsharing 6.0.2 "SocialSharing"
es6-promise-plugin 4.2.2 "Promise"
phonegap-plugin-barcodescanner 8.1.0 "BarcodeScanner"

app.component.ts

import { FCM } from 'cordova-plugin-fcm-with-dependecy-updated/ionic/ngx';
 constructor(
   private fcm: FCM
  ) 

this.platform.ready().then(() => {
      this.fcm.getToken().then(token => {
        console.log(token);
      }, (err) => {
            console.log(err);
        });

      // ionic push notification example
      this.fcm.onNotification().subscribe(data => {
        console.log(data);
        if (data.wasTapped) {
          console.log('Received in background');
          this.router.navigate(['/tabs/tab1/notification']);
        } else {
          console.log('Received in foreground');
          this.call(data);
        }
      });      

      // refresh the FCM token
      this.fcm.onTokenRefresh().subscribe(token => {
        console.log(token);
      }, (err) => {
            console.log(err);
        });
    });

Any help please?

josuelmm commented 2 years ago

Install this plugins https://github.com/healthrecoverysolutions/hrs-cordova-plugin-fcm-with-dependecy-updated