Created
June 23, 2020 16:58
-
-
Save birchb/203df49fed169cc443a1708928bc3495 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const messaging = firebase.messaging(); | |
messaging.usePublicVapidKey(YOUR_PUBLIC_VAPID_KEY_HERE); | |
messaging.onTokenRefresh(() => { | |
messaging.getToken().then(async token => { | |
const subscribeNotifications = firebase.functions().httpsCallable('subscribeNotifications'); | |
await subscribeNotifications({ token }); | |
}); | |
}); | |
messaging.onMessage(payload => { | |
console.log('Message received.', payload); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment