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

1

7

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

Illyes answered 1/5, 2020 at 20:42 Comment(1)
https://mcmap.net/q/1392838/-error-uncaught-in-promise-pushnotifications-does-not-have-web-implementation, i.e. the below answer fixed my problem no need to catch exceptionIllyes
F
29

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

import { Capacitor } from '@capacitor/core';
     
const isPushNotificationsAvailable = Capacitor.isPluginAvailable('PushNotifications');
     
if (isPushNotificationsAvailable) {
     this.initPushNotifications();
}
Fettling answered 7/5, 2020 at 19:44 Comment(1)
Okay, will check and let you know. Hopefully this will work. Thanks for the answer, on confirmation I will mark this as solution answer. Thanks again.Illyes

© 2022 - 2024 — McMap. All rights reserved.