Angular 错误:未捕获(承诺中):PushNotifications没有web实现
如何为web实现捕获此异常,或继续为web执行推送通知 如果有人能帮我,那将非常有帮助。☺ 我已经实现的代码:Angular 错误:未捕获(承诺中):PushNotifications没有web实现,angular,push-notification,ionic4,capacitor,ionic5,Angular,Push Notification,Ionic4,Capacitor,Ionic5,如何为web实现捕获此异常,或继续为web执行推送通知 如果有人能帮我,那将非常有帮助。☺ 我已经实现的代码: PushNotifications.addListener('registrationError', (error: any) => { console.log('Error on registration: ' + JSON.stringify(error)); }); PushNotifications.addListener(
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
中为web实现PushNotification
。如果有插件或者至少我能处理这个异常
请让我知道,如果有任何进一步的澄清,您可以在初始化推送通知之前添加此检查
import { Capacitor } from '@capacitor/core';
const isPushNotificationsAvailable = Capacitor.isPluginAvailable('PushNotifications');
if (isPushNotificationsAvailable) {
this.initPushNotifications();
}
好的,我会检查一下,让你知道。希望这能奏效。谢谢你的回答,确认后我会将此标记为解决方案答案。再次感谢,也就是说,下面的答案解决了我的问题,不需要捕捉异常