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]: Use this plugin with Quasar v2. #46

Open
IvanWala opened this issue Dec 19, 2024 · 0 comments
Open

[Question]: Use this plugin with Quasar v2. #46

IvanWala opened this issue Dec 19, 2024 · 0 comments

Comments

@IvanWala
Copy link

How can we help?

Hi i want to know how use this plugin with quasar v2 in PWA mode and "GenerateSW"

I created a boot file with this code

import { boot } from 'quasar/wrappers'
import OneSignalVuePlugin from '@onesignal/onesignal-vue3'

export default boot(({ app }) => {
    app.use(OneSignalVuePlugin, { appId: 'MI-ONESIGNAL-APP-ID' });
});

It throws correctly the Register message but when it tries to register the One Signal SW i fails beacuse I have the default service worker with this code:

import { register } from 'register-service-worker'

// The ready(), registered(), cached(), updatefound() and updated()
// events passes a ServiceWorkerRegistration instance in their arguments.
// ServiceWorkerRegistration: https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorkerRegistration

register(process.env.SERVICE_WORKER_FILE, {
  // The registrationOptions object will be passed as the second argument
  // to ServiceWorkerContainer.register()
  // https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorkerContainer/register#Parameter

  // registrationOptions: { scope: './' },

  async ready (/* registration */) {
      // console.log('Service worker is active.')
      await caches.keys().then(async(keyList) => {
        return await Promise.all(keyList.map( key => {
                return caches.delete(key);
        }));
      })
  },

  registered (/* registration */) {
    // console.log('Service worker has been registered.')
  },

  cached (/* registration */) {
    // console.log('Content has been cached for offline use.')
  },

  updatefound (/* registration */) {
    // console.log('New content is downloading.')
  },

  updated (/* registration */) {
    // console.log('New content is available; please refresh.')
    window.location.reload(true)
  },

  offline () {
    // console.log('No internet connection found. App is running in offline mode.')
  },

  error (/* err */) {
    // console.error('Error during service worker registration:', err)
  }
})

Someone knows what can I do?

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