-
Notifications
You must be signed in to change notification settings - Fork 8
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
getting error many times t.$OneSignal.isPushNotificationsEnabled is not a function #4
Comments
Have you ever tryed use with async/await? Take a look at: OneSignal Web SDK API This is the code provided on docs: OneSignal.push(function() {
/* These examples are all valid */
OneSignal.isPushNotificationsEnabled(function(isEnabled) {
if (isEnabled)
console.log("Push notifications are enabled!");
else
console.log("Push notifications are not enabled yet.");
});
OneSignal.isPushNotificationsEnabled().then(function(isEnabled) {
if (isEnabled)
console.log("Push notifications are enabled!");
else
console.log("Push notifications are not enabled yet.");
});
}); I can't test locally right now, but i gonna try later using this code: // enable async function
this.$OneSignal.push(async()=> {
this.$OneSignal.isPushNotificationsEnabled((isEnabled)=>{
if (isEnabled)
console.log("Push notifications are enabled!");
else
console.log("Push notifications are not enabled yet.");
});
//use await
const isPushEnabled = await this.$OneSignal.isPushNotificationsEnabled()
if (isPushEnabled){
console.log("Push notifications are enabled!");
} else {
console.log("Push notifications are not enabled yet.");
}
}); |
@imsidz it is works? |
It worked for me 👍🏼, but I refactored this way because logging messages were duplicated: this.$OneSignal.push(async () => {
await this.$OneSignal.isPushNotificationsEnabled((isEnabled) => {
if (isEnabled) console.log('Push notifications are enabled!')
else console.log('Push notifications are not enabled yet.')
})
}) Don't really know if this is correct although OneSignal code docs are provided like that 🤔 Nuxt Version: 2.14.0 |
Anyone using this library? does it work ? I have the codes giving an error. |
Version
v3.0.0-beta.19
Reproduction link
https://github.com/nuxt-community/pwa-module
Steps to reproduce
i install pwa module to my app normaly with
npm i @nuxtjs/pwa @nuxtjs/onesignal
use this to my nuxt.config.jsand added this to my default.vue layout
What is expected ?
it should return
player_id of the subscribed user is : ' + userId
What is actually happening?
t.$OneSignal.isPushNotificationsEnabled is not a function
Additional comments?
i did try to clear cache and refresh it work first time than again return this error
The text was updated successfully, but these errors were encountered: