-
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
OneSignal.push works but $nuxt.$OneSignal.push does not #3
Comments
Are you calling |
@matheuschimelli From a component, vuex store and I also tried from the browser console. |
I'm using OneSignal on a project, so i tested on it. I tested using |
Does it work through the browser console for you? |
Yes it worked. It worked on the first try. |
The onesignal plugin is before the pwa plugin. |
The problem seems to only occur when building via docker. |
I'm not using Docker right now on my projects. I think i can try fix your Dockerfile later. If you fix the file, could you post it here? 😄 |
Yes, I will try to figure out the reason for the problem and post it here. |
I think I found the issue. |
Closing the issue as this is not an issue with the pwa module itself but with my build. |
I got nuxt with pwa and onesignal working in production with docker using the following configuration. Dockerfile
.dockerignore
|
For some reason this started to not work anymore again. I digged into this a little deeper and found out that
OneSignal creates the Here's my guess on why the problem occurs: That being said, I have no clue on why this used to work after updating my Dockerfile or why this works in dev. |
Hi @P4sca1, My issue is same like yours: https://github.com/nuxt-community/pwa-module/issues/263 I don't understand what is the reason, that is not working in a production environment... Any idea? Thanks. |
If I understand correctly, your issue is different from mine, because at least $OneSignal.push works for you all the time. |
My recent build is working for whatever reason. Feels very random. |
In PROD enviroment: In DEV environment all working fine. |
I also noticed unregistering the service worker sometimes fixes the issue and sometimes breaks it again. |
Hi @P4sca1 , I'm downgrade beta version to 2.6.0, and i tested and this it's works both environment: dev/prod. |
Important: I use the window.OneSignal object, with window.$OneSignal or this.$OneSignal it's don't working... |
Interesting, thank you for the info. |
I'm downgrade @nuxt/pwa also 2.6.0, not just onesignal module. @pi0 please support us. :-) Thank you. |
URGENT Subscribe to Notifications
Un-Subscribe from Notifications
<style scoped> #my-notification-button{ position: fixed; bottom: 0; left: 0; padding: 10px; width: 100%; text-align: center; background-color: white; text-decoration: none; color: black; cursor: pointer; } </style> <script> export default { data(){ return { supportedBrowser: false, isSubscribed: false, currentDevice: null } }, mounted(){ this.isSubscribed = this.$auth.loggedIn ? this.$auth.user.notify : false; var OneSignal = window.$OneSignal; OneSignal.push(() => { OneSignal.on('subscriptionChange', this.update); }); this.update(); }, methods: { update(){ this.$OneSignal.push(async () => { var isPushSupported = await this.$OneSignal.isPushNotificationsSupported(); this.supportedBrowser= isPushSupported; if (isPushSupported) { var isEnabled = await this.$OneSignal.isPushNotificationsEnabled(); var deviceId = await this.$OneSignal.getUserId(); this.isSubscribed = isEnabled; this.currentDevice = deviceId; var reqBody = { isSubscribed: this.isSubscribed, currentDevice: this.currentDevice } if (isEnabled) { var response = await this.$axios.post("/users/subscribe", reqBody); } else { console.log("Notifications are not enabled"); var response = await this.$axios.post("/users/unsubscribe", reqBody); } } else { console.log("Does not support notifications"); } }); }, subscribe(){ console.log("here"); this.$OneSignal.push(async () => { console.log("here1"); var isSubscribed = await this.$OneSignal.setSubscription(true); }); }, unsubscribe(){ console.log("here2"); this.$OneSignal.push(async () => { console.log("here3"); var isSubscribed = await this.$OneSignal.setSubscription(false); }); } } } </script>` |
@lovishagg |
@P4sca1 Please let me know if there's an alternative for push notifications which is reliable enough as the project is related to health care and I can not afford to mess up the things in notifications segment of the webapp/PWA |
I know that there are some commercial products available, but I don't have experience with implementing them. Would be great to get this issue sorted out, so that we can use OneSignal reliably with Nuxt.js @pi0 |
I have been looking into this and noticed a couple of things. @P4sca1 Is correct in his observations above. It is what I noticed as well. The behaviour I am consistently noticing This is based on a few breakpoints and examining the network tab. It all breaks and OneSignal doesn't become an So, this is the async issue that OneSignal makes aware of. There isn't really a hook for us to use to let us know when the In any event, despite this being the issue From playing around a lot I believe the issue to be the Now in terms of a decent solution to this. I suppose there could be a few ways.
I am currently going through the nuxt modules docs to try to figure out how to do the former, but in the meantime, the latter would be the following: // change
inject('OneSignal', OneSignal)
// to
inject('OneSignal', () => OneSignal) all forms of This so far has been working for me. If anyone else could try this for there setup to see how resilient it is. If there is any reason not to do it. cool. Just let me know. This is definitely a more workaround solution until further discussion can go into resolving this. @pi0 Edit: When you do I guess meantime just use |
Version
v3.0.0-beta.19
Reproduction link
https://staging.ips-hosting.com
Steps to reproduce
I am having a problem in my production deploy where the callback provided to
$nuxt.OneSignal.push()
is never called.Everything works fine in dev.
Environment:
Here are the results of some tests I did in the browser console:
As you can see
$nuxt.$OneSignal.push
is not working butOneSignal.push
is.I provided the url to my staging deployment where you can test yourself.
What is expected ?
The callback provided to
$nuxt.$OneSignal.push
should also be called in production.What is actually happening?
OneSignal.push
works but$nuxt.$OneSignal.push
does not.Additional comments?
If that helps, here is my
Dockerfile
:OneSignalSDK*
is added to my.dockerignore
.The text was updated successfully, but these errors were encountered: