Open imsidz opened 5 years ago
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.");
}
});
Hi,
I often get this error too: ReplayCallsOnOneSignal.js:23 TypeError: t.$OneSignal.showNativePrompt is not a function
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?
Might be related to nuxt-community/onesignal-module#1 and nuxt-community/onesignal-module#3
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 @nuxtjs/onesignal: 3.0.0-beta.16 @nuxtjs/pwa: 3.0.0-beta.20
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