nuxtjs 单信号配置

nuxtjs onesignal configuration

我遵循了程序https://pwa.nuxtjs.org/modules/onesignal.html#async-functions 形成官方文档网站,但它没有设置

this.$OneSignal.push(() => {
      this.$OneSignal.isPushNotificationsEnabled((isEnabled) => {
        if (isEnabled) {
          console.log('Push notifications are enabled!')
        } else {
          console.log('Push notifications are not enabled yet.')
        }
      })
    })

错误:无法读取 属性 未定义的推送

我是不是漏掉了一些需要设置的东西?

尝试使用全局 window 方法访问它:

// Using window and array form
window.OneSignal.push(['addListenerForNotificationOpened', (data) => {
console.log('Received NotificationOpened:', data )}
]);