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

[Question]: Not able to receive push notification when WebApp is active, Am I missing something ? #41

Open
aman-u-7span opened this issue Aug 9, 2024 · 0 comments

Comments

@aman-u-7span
Copy link

aman-u-7span commented Aug 9, 2024

Not able to receive push notification when WebApp is active, Am I missing something ?

I'm not able to receive notification when tab is active or when I'm on another tab. I'm getting notification only if my tab/website is completely closed. I'm facing same in my PWA as well. When PWA app and website is closed I'm able to receive notification. Am I missing anything ?

main.js

import OneSignal from '@onesignal/onesignal-vue3'

app.use(OneSignal, {
  appId: import.meta.env.VITE_ONE_SIGNAL_APP_ID,
  notifyButton: {
    enable: true
  },
  allowLocalhostAsSecureOrigin: true
})

My one-signal composable

      const isPushNotificationSupported = oneSignalApp.Notifications.isPushSupported()

      await oneSignalApp.Notifications.requestPermission()

      if (
        isPushNotificationSupported &&
        oneSignalApp.Notifications.permission &&
        oneSignalApp.Notifications.permissionNative === 'granted'
      ) {
        /// Here goes my code to save player_id in backend
       }

Package versions

"@onesignal/onesignal-vue3": "^2.0.1",
"vue": "^3.3.11"

Service worker

/public/OneSignalSDKWorker.js -> importScripts("https://cdn.onesignal.com/sdks/web/v16/OneSignalSDK.sw.js");

Any help would be really appreciated. Thanks

@aman-u-7span aman-u-7span changed the title [Question]: [Question]: Not able to receive push notification when WebApp is active, Am I missing something ? Aug 9, 2024
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