-
Notifications
You must be signed in to change notification settings - Fork 1
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
Notifications for duels #189
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My first thoughts on it, before testing 😄 Really excited!
self.importScripts("https://www.gstatic.com/firebasejs/8.2.9/firebase-app.js"); | ||
self.importScripts("https://www.gstatic.com/firebasejs/8.2.9/firebase-messaging.js"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this possible to have these file in our bundle instead of downloading them from a third-party server?
@@ -65,16 +80,64 @@ self.addEventListener("fetch", (e) => { | |||
const newResource = r.clone(); | |||
caches.open(cacheName).then((cache) => { | |||
console.info(`[Service Worker] Caching new resource: ${e.request.url}`); | |||
cache.put(e.request, newResource); | |||
cache.put(e.request, newResource).catch(() => console.error("Can't cache new resource")); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this an error or a simple warning?
client/src/utils/messaging.js
Outdated
class MessagingHandler { | ||
constructor() { | ||
// Information available in the firebase console | ||
this.app = firebase.initializeApp({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good question, I will try
Would it be possible to change |
@FrancoisPog Yes, I am currently doing it on the best merge of my life :) |
Changes
How it works
user
table through/api/v1/messaging/token/add
Issue
The server can send notifications and the service-worker can receive them. On the other hand we encounter a bug when installing and activating firebase on the client.
Screenshots
Request for authorization for notifications:
Notification (here on macOS ❤️ ) when the app is in the background:
Notification when the app is in the foreground: