【问题标题】:Error: Uncaught (in promise): PushNotifications does not have web implementation错误:未捕获(承诺中):PushNotifications 没有 Web 实现
【发布时间】:2021-10-29 03:08:19
【问题描述】:

如何捕获此异常以进行 Web 实现,或继续进行 Web 推送通知。

如果有人可以帮助我,那将非常有帮助。 ☺

我已经实现的代码:

PushNotifications.addListener('registrationError', (error: any) => {
    console.log('Error on registration: ' + JSON.stringify(error));
});

PushNotifications.addListener('pushNotificationReceived', (notification: PushNotification) => {
    console.log('Push received: ' 
        + JSON.stringify(notification.data));

    this.openToast(notification.data);
});

PushNotifications.addListener('pushNotificationActionPerformed', (notification: PushNotificationActionPerformed) => {
    console.log('Push action performed: ' 
        + JSON.stringify(notification.notification.data));

    this.navigate.navigateForward([
        'profile',
        notification.notification.data.identification,
    ]);
});

只是想知道如何在ionic using capacitor 中为网络实现PushNotification。如果有任何插件,或者至少我可以处理这个异常。

如果有任何进一步的说明,请告诉我

【问题讨论】:

标签: angular push-notification ionic4 capacitor ionic5


【解决方案1】:

您可以在初始化推送通知之前添加此检查。

import { Capacitor } from '@capacitor/core';
     
const isPushNotificationsAvailable = Capacitor.isPluginAvailable('PushNotifications');
     
if (isPushNotificationsAvailable) {
     this.initPushNotifications();
}

【讨论】:

  • 好的,会检查并通知您。希望这会奏效。感谢您的回答,确认后我会将其标记为解决方案答案。再次感谢。
猜你喜欢
  • 2020-11-22
  • 1970-01-01
  • 2021-03-25
  • 2018-02-27
  • 2021-11-28
  • 1970-01-01
  • 2022-12-19
  • 2017-10-11
  • 2022-10-20
相关资源
最近更新 更多