【问题标题】:Getting install FCM plugin issue even if plugin is installed即使安装了插件,也会出现安装 FCM 插件的问题
【发布时间】:2020-10-18 17:38:38
【问题描述】:

我正在为我的应用构建推送通知,但是当我在设备上运行我的应用时出现以下错误:

vendor-es2015.js:101693 Native: tried calling FCM.getToken, but the FCM plugin is not installed.
pluginWarn @ vendor-es2015.js:101693
vendor-es2015.js:101699 Install the FCM plugin: 'ionic cordova plugin add cordova-plugin-fcm-with-dependecy-updated'
pluginWarn @ vendor-es2015.js:101699
vendor-es2015.js:101693 Native: tried calling FCM.onNotification, but the FCM plugin is not installed.
pluginWarn @ vendor-es2015.js:101693
vendor-es2015.js:101699 Install the FCM plugin: 'ionic cordova plugin add cordova-plugin-fcm-with-dependecy-updated'
pluginWarn @ vendor-es2015.js:101699
vendor-es2015.js:101693 Native: tried calling FCM.onTokenRefresh, but the FCM plugin is not installed.
pluginWarn @ vendor-es2015.js:101693
vendor-es2015.js:101699 Install the FCM plugin: 'ionic cordova plugin add cordova-plugin-fcm-with-dependecy-updated'
pluginWarn @ vendor-es2015.js:101699
vendor-es2015.js:72492 Angular is running in the development mode. Call enableProdMode() to enable the production mode.
plugins/cordova-sqlite-storage/www/SQLitePlugin.js:175 OPEN database: _ionicstorage
plugins/cordova-sqlite-storage/www/SQLitePlugin.js:106 new transaction is queued, waiting for open operation to finish
vendor-es2015.js:43427 ERROR Error: Uncaught (in promise): plugin_not_installed
    at resolvePromise (polyfills-es2015.js:4153)
    at resolvePromise (polyfills-es2015.js:4110)
    at polyfills-es2015.js:4214
    at ZoneDelegate.invokeTask (polyfills-es2015.js:3747)
    at Object.onInvokeTask (vendor-es2015.js:73280)
    at ZoneDelegate.invokeTask (polyfills-es2015.js:3746)
    at Zone.runTask (polyfills-es2015.js:3524)
    at drainMicroTaskQueue (polyfills-es2015.js:3915)
defaultErrorLogger @ vendor-es2015.js:43427
main-es2015.js:2538 response -> HttpResponse
2vendor-es2015.js:43427 ERROR plugin_not_installed
defaultErrorLogger @ vendor-es2015.js:43427

您可以看到下面的插件已安装,但我仍然收到相同的错误。我尝试卸载并再次安装它,我再次删除并添加了平台,但仍然出现同样的错误。

下面是 Ionic Info 命令的输出:

Ionic:

   Ionic CLI                     : 6.1.0 (/usr/local/lib/node_modules/@ionic/cli)
   Ionic Framework               : @ionic/angular 5.2.2
   @angular-devkit/build-angular : 0.803.27
   @angular-devkit/schematics    : 9.1.9
   @angular/cli                  : 8.3.27
   @ionic/angular-toolkit        : 2.2.0

Capacitor:

   Capacitor CLI   : 1.5.0
   @capacitor/core : 1.5.0

Cordova:

   Cordova CLI       : 9.0.0 (cordova-lib@9.0.1)
   Cordova Platforms : android 8.1.0, browser 6.0.0
   Cordova Plugins   : cordova-plugin-ionic-keyboard 2.2.0, cordova-plugin-ionic-webview 4.1.3, (and 13 other plugins)

Utility:

   cordova-res (update available: 0.15.1) : 0.11.0
   native-run (update available: 1.0.0)   : 0.3.0

System:

   NodeJS : v10.15.1 (/usr/local/bin/node)
   npm    : 6.11.3
   OS     : macOS High Sierra
   Xcode  : Xcode 10.1 Build version 10B61

ionic cordova plugin list
> cordova plugin ls
com-sarriaroman-photoviewer 1.2.4 "PhotoViewer"
com.razorpay.cordova 0.16.1 "RazorpayCheckout"
cordova-android-support-gradle-release 3.0.1 "cordova-android-support-gradle-release"
cordova-plugin-androidx-adapter 1.1.1 "cordova-plugin-androidx-adapter"
cordova-plugin-cocoapod-support 1.6.2 "Cordova CocoaPods Dependency Support"
cordova-plugin-device 2.0.2 "Device"
cordova-plugin-fcm-with-dependecy-updated 7.0.0 "Cordova FCM Push Plugin"
cordova-plugin-ionic-keyboard 2.2.0 "cordova-plugin-ionic-keyboard"
cordova-plugin-ionic-webview 4.1.3 "cordova-plugin-ionic-webview"
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 5.6.5 "SocialSharing"
cordova-sqlite-storage 5.0.0 "Cordova sqlite storage plugin - cordova-sqlite-storage plugin version"
cordova-support-android-plugin 1.0.2 "cordova-support-android-plugin"
cordova-support-google-services 1.4.1 "cordova-support-google-services"
es6-promise-plugin 4.2.2 "Promise"

【问题讨论】:

    标签: cordova ionic-framework cordova-plugins ionic-native ionic5


    【解决方案1】:

    根据文档here,对于 Ionic 5 应用程序,cordova-plugin-fcm-with-dependecy-updated 插件的使用应与 Ionic 4 稍有不同。

    对于我的 Ionic 5 应用,我只是将其导入到 app.component.ts 中,如下所示(即作为工厂类):
    import { FCM } from "cordova-plugin-fcm-with-dependecy-updated/ionic";

    并在平台准备好时使用它:

    platform.ready().then(() => {
      // Some code ..
      FCM.getToken().then(token => {
        console.log(token);
      }, error => { console.log(error) });
    
      // More code ..
    });

    此外,根据此插件的文档,不再需要 @ionic-native/fcm 包。但是,我还没有在 IOS 上测试过这个。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-01-29
      • 2023-04-09
      • 2011-01-23
      相关资源
      最近更新 更多