OneSignal / OneSignal-Cordova-SDK

OneSignal is a free push notification service for mobile apps. This plugin makes it easy to integrate your Ionic, PhoneGap CLI, PhoneGap Build, Cordova, or Sencha Touch app with OneSignal. Supports Android, iOS, and Amazon's Fire OS platforms. https://onesignal.com
Other
251 stars 199 forks source link

In Cordova IOS Platform, onesignal is initialized, but i'm not getting any notifications? It works fine in android #998

Closed Dev-Pradeep-NS closed 6 months ago

Dev-Pradeep-NS commented 6 months ago

How can we help?

if (window.plugins && window.plugins.OneSignal) {
        var onesignalKey = "provided key here"
        window.plugins.OneSignal.initialize(onesignalKey);

    let handleNotificationReceived = function (jsonData) {
        C('Did I receive a notification: ', jsonData);
        let notification = jsonData.notification;
        if (notification.title) {
            that.annoDialog('<b>' + notification.title + '</b><br><br>' + notification.body);
        } else {
            that.showDialog(notification.body);
        }
    };
    window.plugins.OneSignal.Notifications.addEventListener("foregroundWillDisplay", handleNotificationReceived);

    const handleNotificationOpened = (jsonData) => {
        const notificationPayload = JSON.stringify(jsonData);
        that.redirectTo('app/events/upcoming');
        console.log(notificationPayload);
    };
    window.plugins.OneSignal.Notifications.addEventListener("click", handleNotificationOpened);

    window.plugins.OneSignal.Notifications.requestPermission(true).then((accepted) => {
        console.log("User accepted notifications: " + accepted);
    });
}

Code of Conduct

Dev-Pradeep-NS commented 6 months ago

I'm closing this issue, as no one responding to this