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

OneSignal instance is not consistant, when reloading the page #33

Open
julianschmuckli opened this issue Oct 10, 2021 · 1 comment
Open

Comments

@julianschmuckli
Copy link

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:
class Bi{static setDefaultNotificationUrl(e){return Object(d.a)(this,void 0,void 0,function*(){if(!Ri.isValidUrl(e,{allowNull:!0}))throw new InvalidArgumentError.a("url",InvalidArgumentError.b.Malformed);y…

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.
OneSignalStubES6 {VERSION: 151508, log: {…}, directFunctionCallsArray: Array(0), preExistingArray: Array(1), on: ƒ, …}

@cingh-jasdeep
Copy link

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!

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

2 participants