onesignal-module
onesignal-module copied to clipboard
OneSignal instance is not consistant, when reloading the page
I try to implement the module in my Nuxt page. But it seems it does not work properly every time.
I have setup the nuxt.config.js as follow:
// One Signal
oneSignal: {
init: {
appId: "****",
safari_web_id: "web.onesignal.auto.****",
allowLocalhostAsSecureOrigin: true,
welcomeNotification: {
disable: true
},
promptOptions: {
slidedown: {
prompts: [
{
type: "category",
autoPrompt: true,
text: {
actionMessage:
"Abonniere verschiedene Themen von ABC und bleibe auf dem Laufenden.",
acceptButton: "Abonnieren",
cancelButton: "Später",
/* CATEGORY SLIDEDOWN SPECIFIC TEXT */
negativeUpdateButton: "Abbrechen",
positiveUpdateButton: "Aktualisieren",
updateMessage:
"Ändere dein Abonnement um verschiedene Themen von ABC zu erhalten."
},
delay: {
pageViews: 2,
timeDelay: 20
},
categories: [
{
tag: "portfolio",
label: "Portfolio"
},
{
tag: "projects",
label: "Projekte"
},
{
tag: "general",
label: "Generell"
}
]
}
]
}
}
}
},
// .....
modules: [
// https://go.nuxtjs.dev/axios
"@nuxtjs/axios",
"@nuxtjs/onesignal",
"@nuxtjs/pwa",
["vue-scrollto/nuxt", { duration: 300 }]
],
And there is an method where I want to show the category slidedown:
async open() {
console.log(this.$OneSignal)
try {
await this.$OneSignal.showCategorySlidedown({ force: true });
} catch (e) {
console.error(e);
}
},
Because when it works, the output of this.$OneSignal
instance is:
Now when I reload the page and the showCategorySlidedown
function does not work, but does not give any warning. Instead I checked the instance again and it looks like an other instance.
Sat Sri Akal ji I ran into many issues with this module
ended up doing typical install onesignal https://documentation.onesignal.com/v7.0/docs/web-push-typical-setup
and changed scope of onesignal service worker https://documentation.onesignal.com/docs/onesignal-service-worker-faq#customizing-your-service-worker-integration
also adding one signal script in nuxt application head through app.html https://github.com/gpmkc-moga/gpmkc-moga.github.io/blob/972718a9c59c466d5a494e5584fe85ef870894cc/app.html#L5
hope this helps someone!