-
Notifications
You must be signed in to change notification settings - Fork 3
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
[Question]: Push notification permission state resets after PWA application is closed. Is it normal ? #45
Comments
@Ratatinator97 How are you reopening the PWA after closing it? If this lines up with what you are seeing then you can use the following workaround: |
By just clicking on the application in the Home Screen. I have deactivated the "notification enabled popup". The issue still persists. Thank you a lot for your reply, I will check the apple dev forum closely. |
@Ratatinator97 Maybe this helps. I noticed a bug in my example code. If I slightly modified the code, so that bell state is updated after OneSignal has been initialized. (@onesignal/onesignal-vue3 does not export their interfaces, so I had to use // plugins/onesignal.client
// ...
const OneSignal = useOneSignal() as ReturnType<typeof useOneSignal> & { initialized: Promise<boolean> };
OneSignal.initialized = new Promise((resolve) => {
OneSignal.init({
appId,
allowLocalhostAsSecureOrigin: process.env.APP_ENV !== 'production',
}).then(() => resolve(true)).catch(() => resolve(false));
});
// ... <!-- components/OneSignalSubscribeButton.vue -->
<!-- ... -->
onBeforeMount(() => {
$OneSignal.initialized.then(updateBellState);
$OneSignal.Notifications.addEventListener('permissionChange', onPermissionChange);
$OneSignal.User.PushSubscription.addEventListener('change', onSubscriptionChange);
});
<!-- ... --> |
Thank you for your code snippets, but it didn't fix my issue with iOS... I'm waiting for iOS 17.4 to be released and test it. |
How can we help?
Hello,
I want to use push notifications for my iOS PWAs and iPadOS PWAs.
I use iOS 17.2.1 and iPadOS 17.2 on an iPhone 13 Pro Max and iPad Pro 11".
I don't know if it is a bug that
$OneSignal.Notifications.permission
and$OneSignal.User.PushSubscription.optedIn
reset after the application is closed. The issue does not appear in macOS 14.2.1 in Safari or PWA with Chrome.I have been using this code with a different service worker scope:
/push/onesignal/
.I am able to receive push notifications even when the
$OneSignal.Notifications.permission
and$OneSignal.User.PushSubscription.optedIn
appear as false on both iOS and iPadOS.Is it normal ?
The text was updated successfully, but these errors were encountered: