Adds onesignal push notifications to quasar framework apps.
web,pwa and corodova are supported
yarn add quasar-app-extension-onesignal
quasar ext invoke onesignal
For pwa mode, edit the generated src-pwa/register-service-worker.js
and change
register(process.env.SERVICE_WORKER_FILE, {
to register('/OneSignalSDKWorker.js', {
Extends vue components and the app with $oneSignal:
$vm.$oneSignal === {
get Instance (): Object|Array; // returns window.OneSignal
setup (appId: string, initConfig?: Object) ;
optIn (extenalUserId?: string);
optout ();
}
// setup one signal
app.$oneSignal.setup(process.env.ONESIGNAL_APP_ID)
store.watch(
() => store.state.auth.user,
function (user) {
if (user) {
// optin using an optional external_user_id
app.$oneSignal.optIn(user.push_id)
} else {
// optout
app.$oneSignal.optOut()
}
}
)