OneSignal / onesignal-vue

Vue OneSignal Plugin: Make it easy to integrate OneSignal with your Vue App!
Other
13 stars 2 forks source link

[Bug]: Cannot showNativePrompt #40

Closed bmulholland closed 1 year ago

bmulholland commented 1 year ago

What happened?

error: $OneSignal.showNativePrompt is not a function

What browsers are you seeing the problem on?

Firefox, Chrome (Chromium)

What operating system are you running?

latest macos

Steps to reproduce?

docs say https://documentation.onesignal.com/docs/native-browser-prompt#custom-code-native-prompt

so do nuxtApp.$OneSignal.showNativePrompt

What did you expect to happen?

-

Relevant log output

No response

jkasten2 commented 1 year ago

@bmulholland Thanks for reporting this issue. We recently released a major release and missed updating this documentation page. An update is going out shortly to fix the documentation.

In the meantime the replacement method for OneSignal.showNativePrompt() is OneSignal.Notifications.requestPermission()

Also I can say this page is updated with the latest SDK API: https://documentation.onesignal.com/docs/web-sdk#enabling-a-push-subscription

bmulholland commented 1 year ago

Well no, actually, that isn't a replacement. In Firefox, that has a hardcoded requirement to show the slidedown prompt, which I don't want -- we already have a soft opt-in, so the user has just fulfilled Firefox's interaction requirement.

https://github.com/OneSignal/OneSignal-Website-SDK/blob/53bbca300aae4f73baa5cf2e40644dcb387148dd/src/page/helpers/EnvironmentInfoHelper.ts#L64

https://github.com/OneSignal/OneSignal-Website-SDK/blob/53bbca300aae4f73baa5cf2e40644dcb387148dd/src/onesignal/NotificationsNamespace.ts#L128

bmulholland commented 1 year ago

Oh and actually, with my settings, the slidedown prompt is disabled, so just nothing happens in Firefox...

Honestly this is like the third or fourth time I'm digging into the library code to detect basic bugs. This should never have been released like this.

bmulholland commented 1 year ago

I've patched it for now with:

          window.OneSignalDeferred?.push((OneSignal) => {
            OneSignal.context.promptsManager.internalShowNativePrompt()
          })