Skip to content

Commit

Permalink
Merge pull request #309 from ymaheshwari1/fix/notification-error
Browse files Browse the repository at this point in the history
Fixed: issue when Notification api is not available on browser
  • Loading branch information
ravilodhi authored Jul 11, 2024
2 parents 722633c + ab63cbb commit 0ef0e16
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/utils/firebase.ts
Original file line number Diff line number Diff line change
@@ -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,
Expand All @@ -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();
Expand Down

0 comments on commit 0ef0e16

Please sign in to comment.