You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[Bug]: ReplayCallsOnOneSignal.js:6 Uncaught TypeError: e is not iterable at o.processOneSignalDeferredArray, facing this issue whenever my app loads.
#1190
Closed
aman-u-7span opened this issue
Sep 6, 2024
· 6 comments
oneSignal.js (File i'm using to initialize one signal in the app)
async function getAccessToken() {
try {
window.OneSignalDeferred = window.OneSignalDeferred || []
OneSignalDeferred.push(async function (OneSignal) {
await OneSignal.init({
appId: import.meta.env.VITE_ONE_SIGNAL_APP_ID,
notifyButton: {
enable: true
}
})
const isPushNotificationSupported = OneSignal.Notifications.isPushSupported()
await OneSignal.Notifications.requestPermission()
if (
isPushNotificationSupported &&
OneSignal.Notifications.permission &&
OneSignal.Notifications.permissionNative === 'granted'
) {
console.log(OneSignal.User.PushSubscription.id)
/* Code to save id in backend */
} else {
toast.notify({
title: 'Check browser settings to recieve push notifications.',
type: 'warning'
})
}
})
} catch (error) {
console.log(error)
handleGlobalError(error)
}
}
I'm not sure what i'm doing wrong, Onesignal-vue3 plugin didn't workout for me so had to use web-sdk for this one. Any guidance would be really helpful.
What browsers are you seeing the problem on?
Chrome (Chromium), Safari, Brave
What operating system are you running?
macOS monterey 12.7.1
Steps to reproduce?
Just use my code with vue3 and start the app with `npm run dev`
What did you expect to happen?
I expected it to work normally and also found that push notifications are bit inconsistence.
Relevant log output
No response
The text was updated successfully, but these errors were encountered:
@aman-u-7span Isn't there a call somewhere to OneSignalDeferred.push() before this getAccessToken method is called? It looks like the window.OneSignalDeferred = window.OneSignalDeferred || [] initialization should be earlier
@aman-u-7span For me, this error is reproduced only if window.OneSignalDeferred is not yet defined before the first call to window.OneSignalDeferred.push(). Therefore, I clarified - is window.OneSignalDeferred initialized before the first call to window.OneSignalDeferred.push()?
Ahh okay I got it. I was able to resolve the issue by initialising script manually and then defining the window.OneSignalDeferred. Thanks a lot mate @aleksi-magner
What happened?
I'm using Vue3
index.html
oneSignal.js (File i'm using to initialize one signal in the app)
I'm not sure what i'm doing wrong, Onesignal-vue3 plugin didn't workout for me so had to use web-sdk for this one. Any guidance would be really helpful.
What browsers are you seeing the problem on?
Chrome (Chromium), Safari, Brave
What operating system are you running?
macOS monterey 12.7.1
Steps to reproduce?
What did you expect to happen?
I expected it to work normally and also found that push notifications are bit inconsistence.
Relevant log output
No response
The text was updated successfully, but these errors were encountered: