Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error: Uncaught (in promise): PushNotifications does not have web implementation

How to catch this exception for web implementation, or to proceed with Push Notification for web.

If anyone can help me with it, it will be very helpful. ☺

Code that I have implemented:

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,
    ]);
});

Just wanted to know how to implement PushNotification for web in ionic using capacitor. if there is any plugin or atleast if I can handle this exception.

Please let me know, in case of any further clarification

like image 944
Dibyendu Saha Avatar asked Dec 05 '22 08:12

Dibyendu Saha


1 Answers

You can add this check before initializing your push notifications..

import { Capacitor } from '@capacitor/core';
     
const isPushNotificationsAvailable = Capacitor.isPluginAvailable('PushNotifications');
     
if (isPushNotificationsAvailable) {
     this.initPushNotifications();
}
like image 124
Chetan Bansal Avatar answered Jan 11 '23 08:01

Chetan Bansal