【问题标题】:Ionic Capacitor "PushNotifications" plugin is not implemented on android离子电容器“PushNotifications”插件未在 android 上实现
【发布时间】:2021-10-31 17:04:39
【问题描述】:

我在尝试使用 @capacitor/push-notifications 插件请求权限时遇到问题。我按照自述文件中描述的每个步骤进行操作,并且使用的是 Ionic 和 Vue 3。

这是package.json

...
    "@capacitor/android": "^3.2.0",
    "@capacitor/core": "^3.2.0",
    "@capacitor/push-notifications": "^1.0.3",
    "@ionic/vue": "^5.4.0"
...

这是请求权限的方法:

requestFCMPermissions(context: AuthContext) {
      PushNotifications.requestPermissions().then(result => {
        if (result.receive === "granted") {
          PushNotifications.register();
          ...
        } else {
          ...
        }
      });
      ...
}

当然,这在通过 Web 尝试时不起作用,但是,当我组装一个 APK 和配置文件时,它会在控制台日志中响应我一个错误:

 "PushNotifications" plugin is not implemented on android

有人知道为什么吗?谢谢!

【问题讨论】:

    标签: android firebase vue.js ionic-framework


    【解决方案1】:

    解决了我在编辑MainActivity.java 文件时遇到的问题:

    public class MainActivity extends BridgeActivity {
      @Override
      public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
     
        // Initializes the Bridge
        this.init(savedInstanceState, new ArrayList<Class<? extends Plugin>>() {{
          // Additional plugins you've installed go here
          //...
          add(com.capacitorjs.plugins.pushnotifications.PushNotificationsPlugin.class);
        }});
      }
    }
    

    但这在任何教程中都没有指定,所以它可能适合我的配置。

    【讨论】:

      猜你喜欢
      • 2020-11-22
      • 1970-01-01
      • 1970-01-01
      • 2019-08-14
      • 2020-11-24
      • 2022-10-20
      • 2021-04-13
      • 2020-09-25
      • 1970-01-01
      相关资源
      最近更新 更多