Last active
March 17, 2022 19:58
-
-
Save splintor/404d9d4a820e2c8dfbe6729a79365fed to your computer and use it in GitHub Desktop.
getToken function with Firebase 8
This file contains 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
import firebase from 'firebase/app'; | |
import 'firebase/messaging'; | |
import { getConfig, getPublicKey, registerServiceWorker } from './firebase'; | |
export async function getFirebaseToken() { | |
firebase.initializeApp(getConfig()); | |
return firebase.messaging().getToken({ | |
vapidKey: getPublicKey(), | |
serviceWorkerRegistration: await registerServiceWorker(), | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment