我遵循了程序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.')
}
})
})
错误:无法读取未定义的属性推送
我想念一些需要设置的东西吗?
答案 0 :(得分:1)
尝试使用全局窗口方法访问它:
// Using window and array form
window.OneSignal.push(['addListenerForNotificationOpened', (data) => {
console.log('Received NotificationOpened:', data )}
]);