File tree Expand file tree Collapse file tree 1 file changed +4
-3
lines changed
Expand file tree Collapse file tree 1 file changed +4
-3
lines changed Original file line number Diff line number Diff line change @@ -8,13 +8,13 @@ import { initializeApp } from 'firebase/app';
88import { APP_DATA , FIREBASE_CONFIGS } from '@/shared/constants' ;
99import { isLocal } from '@/shared/helpers' ;
1010
11- const FIREBASE_APP = initializeApp ( FIREBASE_CONFIGS ) ;
12- const FIREBASE_MESSAGING = getMessaging ( FIREBASE_APP ) ;
11+ const FIREBASE_APP = FIREBASE_CONFIGS . projectId ? initializeApp ( FIREBASE_CONFIGS ) : null ;
12+ const FIREBASE_MESSAGING = FIREBASE_APP ? getMessaging ( FIREBASE_APP ) : null ;
1313
1414export async function requestNotificationPermission ( ) {
1515 try {
1616 const permission = await Notification . requestPermission ( ) ;
17- if ( permission === 'granted' ) {
17+ if ( permission === 'granted' && ! ! FIREBASE_MESSAGING ) {
1818 const token = await getMessagingToken ( FIREBASE_MESSAGING , {
1919 vapidKey : import . meta. env . VITE_FIREBASE_VAPID_KEY ?? null
2020 } ) ;
@@ -32,6 +32,7 @@ export async function requestNotificationPermission() {
3232
3333export function onMessageListener ( ) {
3434 return new Promise ( ( resolve ) => {
35+ if ( ! FIREBASE_MESSAGING ) return ;
3536 onMessage ( FIREBASE_MESSAGING , ( payload ) => {
3637 resolve ( payload ) ;
3738 } ) ;
You can’t perform that action at this time.
0 commit comments