Skip to content

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

@julianschmuckli

Description

@julianschmuckli

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: ƒ, …}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions