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]: Safari permissions issue on onesignal permissions prompt #144

Open
mramzan18 opened this issue May 29, 2024 · 9 comments
Open

[Bug]: Safari permissions issue on onesignal permissions prompt #144

mramzan18 opened this issue May 29, 2024 · 9 comments

Comments

@mramzan18
Copy link

What happened?

The Safari site URL, icon size, or push certificate is invalid, or Safari is in a private session.
whenever OneSignal.Slidedown.promptPush() is executed, prompt shown on safari browser and user click on allow button it instantly show this message 'The Safari site URL, icon size, or push certificate is invalid, or Safari is in a private session.' inside console and do not receive any push notifications. i tried to remove notification icon on onesignal dashboard as well .p12 file as well

import { useEffect, useState } from 'react'
import OneSignal from 'react-onesignal'
import { useSelector } from './useAppSelector'

const useOneSignalConfig = () => {
const { oneSignalExternalId } = useSelector(({ auth }) => auth)

const [isInitialized, setIsInitialized] = useState(false)

useEffect(() => {
    const initOneSignal = async () => {

        try {
            
            await OneSignal.init({
                appId: import.meta.env.VITE_ONESIGNAL_APP_ID, // Replace with your actual OneSignal App ID
                 allowLocalhostAsSecureOrigin: true, // This line is important for local development
                serviceWorkerPath: '/OneSignalSDKWorker.js', // Ensure this points to the correct service worker file
            })
            
            await OneSignal.Slidedown.promptPush()

            setIsInitialized(true)
        } catch (error) {
           
        }
    }

    initOneSignal()
}, [])

useEffect(() => {
    const loginOneSignal = async () => {
        try {
            await OneSignal.login(String(oneSignalExternalId))
           
        } catch (error) {
            
        }
    }

    if (isInitialized && oneSignalExternalId) {
        loginOneSignal()
    }
}, [isInitialized, oneSignalExternalId])

return { isInitialized }

}

export { useOneSignalConfig }

What browsers are you seeing the problem on?

Safari

What operating system are you running?

macOS Sonoma 14.4.1

Steps to reproduce?

using "react-onesignal": "^3.0.1",

What did you expect to happen?

Push notifications on safari

Relevant log output

No response

@jkasten2
Copy link
Member

@mramzan18 This could be happening due to a macOS bug that happens some systems. Can you try the repo steps here to isolate the problem?
https://forums.developer.apple.com/forums/thread/746498

@sanishkr
Copy link

I am getting this error on onesignal prompt click as well "The Safari site URL, icon size, or push certificate is invalid, or Safari is in a private session." [safari desktop] v:17.4.1

Its documentation says, no need to add push certificate after safari 15.
I am sure, I am not using private session.
And other 2 reason, likely not an issue, with same site, I tried on safari ios (after adding site to home screen), it works fine.

Dont know what else to check. At least, some way to find that this browser cant get notification, so I can disable my button on site can help.

@jkasten2
Copy link
Member

jkasten2 commented Jun 5, 2024

@sanishkr can you check if this is due to your system being affected by the Apple bug I noted above?

Here is a direct link to the MRE (minimal reproducible example):
https://public-mre-macos-window-safari-prompt-bug.glitch.me/

@sanishkr
Copy link

sanishkr commented Jun 6, 2024

I tried, it gives this as response in box below:
SafariLegacy.subscribe:response:{"deviceToken":null,"permission":"denied"}

@mramzan18
Copy link
Author

@sanishkr have you found any solution?

@sanishkr
Copy link

Nope, not even any workaround yet. It is either with onesignal devs or safari devs from apple to fix this.

@mramzan18
Copy link
Author

@jkasten2
Safari Version 17.4.1 (19618.1.15.11.14)
Screenshot 2024-06-10 at 1 25 21 PM

@mramzan18
Copy link
Author

@sanishkr if you found any workaround then let me know as well

@finalgamer
Copy link

I just got the following message from OneSignal support

This issue has been resolved by upgrading to macOS 14.5 and Safari 17.5.

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

4 participants