OneSignal / OneSignal-WordPress-Plugin

OneSignal is a free push notification service for web and mobile apps. This plugin makes it easy to integrate your website with OneSignal Push Notifications. https://onesignal.com
Other
80 stars 42 forks source link

[Bug]: Getting subscription state not working in Safari #317

Closed YourMark closed 1 month ago

YourMark commented 1 year ago

What happened?

Hello,

We have a page on our website that displays the settings for OneSignal. It uses the following code to get the current state of a visitor.

function getSubscriptionState() {
    return Promise.all([
        OneSignal.getNotificationPermission(),
        OneSignal.isPushNotificationsEnabled(),
        OneSignal.isOptedOut()
    ]).then(function (result) {
        return {
            permission: result[0],
            isPushEnabled: result[1],
            isOptedOut: result[2]
        };
    });
}

However in some (well, almost all) occasions this causes issues with Safari/macOS 13.5 and Safari/iOS 16.6 (up-to-date).

If you visit our push configuration page for the first time, there is no issue and the designated radio buttons appear. However, if you navigate away from this page and then return, the radio buttons won't show anymore.

The radio buttons are dynamically shown with a small block of a JavaScript on our end, but what we're seeing is that Onesignal doesn't return the correct push state(s) (configured segments) and is therefore unable to show the correct radio buttons/options. We now believe the IndexedDB in Safari is immediately emptied when navigating away from this specific page, and therefore is unable to retrieve the correct Onesignal options in subsequent visits.

Please note we believe this to a Safari specific issue, as we don't see the same behaviour in Chrome, Firefox and/or Edge.

https://github.com/OneSignal/OneSignal-WordPress-Plugin/assets/1590375/186acdab-3809-4763-b214-0b4222aad1fa

Wordpress version

6.2.2

OneSignal Plugin version

2.4.0

Steps to reproduce?

1. Go to https://www.iculure.nl/push/
2. See that there is an option with radio buttons
3. Navigate away from this page, for instance by going to 'Nieuws' or any other page.
4. Go pack to /push/ by clicking on the monitor icon in the top bar.
5. Notice the radio buttons don't appear.

See the attached video above for an example

What did you expect to happen?

I'm expecting either a response from the Promis or the IndexedDB not to be emptied :-)

Relevant log output

No response

Code of Conduct

sherwinski commented 1 month ago

Hi, we have had no further reports of this. Please upgrade the OneSignal SDK if you or anyone is still having this issue. If this is still an issue, please open a new report with updated information and we will investigate. Thanks