Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
1 task done
YourMark opened this issue Jul 27, 2023 · 0 comments
Open
1 task done

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

YourMark opened this issue Jul 27, 2023 · 0 comments

Comments

@YourMark
Copy link

YourMark commented Jul 27, 2023

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.

example.mp4

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

  • I agree to follow this project's Code of Conduct
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant