Table Of Contents
Updating the Service Worker registration
Making an update mixin
Updating our UI
Skipping Service Working waiting
Upda...
For further actions, you may consider blocking this person and/or reporting abuse
I just found out that this article is being included in the Vue.js Developer Newsletter which is pretty exciting!
If you found this article via the newsletter let me know.
I am not totally sure, but I think it would be fair to add a reference to this article on medium medium.com/@dougallrich/give-users... where the author explains this whole concept. I coded my version of a PWA with updated SW last year based on this article and I found that your code samples are more or less identical to what is described in this article.
Wow, that is super similar in code examples. I read a bunch of different articles and docs while I was working on my solution. Somehow, I didn't see this one.
Thanks for this link and the idea. Maybe I can add a list of different articles that take a similar approach to this problem.
YOU saved my life.
To automatically show the update banner, add this in service worker :
dev-to-uploads.s3.amazonaws.com/up...
Hi man, thanks again for this amazing article. i just stumbled into an issue, i'm not sure how to explain this though. but when i deploy a version of my code to production it still uses the reference to the old fines generated by the build. for example. The newly generate build files in my index.html are
/js/chunk-vendors.3c199704.js
however my webapp tries to reference an old generate file which isn't existing.Note that when i clear the catch everything starts working properly. I don't really know what is going on at this point. Please anyone knows how i can fix this?
Anyone has any idea on how to fix this issue? again it was working pretty well but started bugging in production lately!
Thanks for this awesome article man... really helped!
Thank you, Lord! You just saved my sanity – or what's left of it after struggling with this for 2 days! Amazing! Thank you so much for this! 🙌 🙌 🙌
tiny fix: there seems to be a comma missing between updateAvailable and refreshApp in methods.
Great! The whole reason I wrote this up was to help someone dealing with the same issue. I'm super happy I could help.
Thanks for the heads up on the comma 🤦♂️
In my blog this
updated(registration)
method is called on every page reload and it show in console that 'New content is available; please refresh.'Is this usual for PWA or I missed something ?
dev.adapttive.com
Hey Milind, that doesn't sound right to me. Did you follow the above example exactly?
Yes, I found the issue.
I had add the onesignal sdk for notifications, which has a service worker causing conflit with default website service worker. 🙂
Thank you for this wonderful article. This is working fine if we refresh the page and showing an update prompt. But this not working without a refreshing page. Especially in the case of SPA. Please help me to show update prompt without refresh page
I had the same question. Turns out you can create an interval to poll for updates in
registerServiceWorker.js
:This works perfectly ! thanks !
Hi. I want to ask. I had try your code and it works. I don't want to show the snackbar message. So I deleted this code :
<v-snackbar bottom right :value="updateExists" :timeout="0" color="primary">
. It worked and there were no problems. Changes are automatically updated without clicking the update button. How do you think?An update is available
<v-btn text @click="refreshApp">
Update
</v-btn>
</v-snackbar>
I try another option like this :
methods: {
. So if detect new version, it immediately called refreshApp method. So user don't need to click the update buttonupdateAvailable (event) {
this.registration = event.detail
this.updateExists = true
this.refreshApp()
}
Snackbar with UPDATE button never goes away on Chrome/Firefox even after reloading, works as expected on Safari. Any help is appreciated @drbragg
Could be a change in a newer of Vue or Vuetify. Or heck, could be a change in how
register-service-wroker
works (judging by some of the other comments). It's been a while since I worked with this. If it helps these were my dependency versions at the time:@drbragg figured out, it was problem with using firebase serviceWorker being loaded at the same time. Thanks for this article, highly appreciate that
Awesome! Glad you were able to figure it out!
@drbragg thanks for responding. I’ll check it out
Hi @rdj
I'm trying to use this system and at the same time i have FCM on my project.
How did you solve that situation?
thankyou
Awesome bro. Thank you.
This saved my day!...It works flawless. Great! sollution.
awesome bro, like a charm <3 . thank you
Was searching for this exact code. Awesome! Thanks a bunch of headache!
Thank you! This was very helpful!
Thanks a million.
Thank you for the kind words! I hope it helped you.
Excelent! Thanks!!
I don't get where exactly to add the self.addEventListener code
Anyone thought of doing a composition api variation?
Great article
Not doing much with Vue any more unfortunately. Maybe someday