diff --git a/src/utils/firebase.ts b/src/utils/firebase.ts index 7ca8626..02017a9 100644 --- a/src/utils/firebase.ts +++ b/src/utils/firebase.ts @@ -1,5 +1,5 @@ import { initializeApp } from "firebase/app"; -import { getMessaging, getToken, onMessage } from "firebase/messaging"; +import { getMessaging, getToken, onMessage, isSupported } from "firebase/messaging"; const initialiseFirebaseApp = async ( appFirebaseConfig: any, @@ -9,6 +9,11 @@ const initialiseFirebaseApp = async ( ) => { const firebaseConfig = appFirebaseConfig + if(!await isSupported()) { + console.error("Notifications not supported"); + return; + } + const app = initializeApp(firebaseConfig); const messaging = getMessaging(app); const permission = await Notification.requestPermission();