cordova 即使已安装插件,也会出现安装FCM插件问题

7qhs6swi  于 2022-11-15  发布在  其他
关注(0)|答案(3)|浏览(277)

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

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:

   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"
piok6c0g

piok6c0g1#

对于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呢。

dluptydi

dluptydi2#

我也得到了这个问题。下面是解决我的问题的步骤。
安装以下插件:

  1. cordova插件添加cordova插件-androidx适配器。
  2. cordova插件添加cordova-插件-androidx;
    然后:
import { FCM } from "cordova-plugin-fcm-with-dependecy-updated/ionic";

获取内标识:

FCM.gettoken().then(res=>{

})
d6kp6zgx

d6kp6zgx3#

我也一直面临同样的问题超过1小时,但现在发现是使用:
import { FCM } from '@awesome-cordova-plugins/fcm/ngx';
而不是:
import { FCM } from 'cordova-plugin-fcm-with-dependecy-updated/ionic/ngx';

相关问题