@@ -6,6 +6,7 @@ import { getToken, Messaging, onMessage } from '@firebase/messaging';
66import { PACKAGE_NAME } from './package-name' ;
77import { LinkName } from './link-name' ;
88import { getDeviceRegistrationTokenInsertSerialOperations } from './get-device-registration-token-insert-serial-operations' ;
9+ import createDebugMessage from 'debug' ;
910
1011/**
1112 * Registers device
@@ -45,37 +46,6 @@ export async function registerDevice({
4546
4647 onDeviceRegistration ( { value : deviceRegistrationToken } ) ;
4748
48- onMessage ( firebaseMessaging , async ( payload ) => {
49- console . log (
50- '[firebase-messaging-sw.js] Received background message ' ,
51- payload
52- ) ;
53- if ( ! payload . notification ) {
54- return ;
55- }
56- if ( ! payload . notification . title ) {
57- return ;
58- }
59-
60- // Let's check if the browser supports notifications
61- if ( ! ( 'Notification' in window ) ) {
62- throw new Error ( 'This browser does not support desktop notification' ) ;
63- }
64-
65- // Let's check whether notification permissions have already been granted
66- else if ( Notification . permission === 'granted' ) {
67- // If it's okay, let's create a notification
68- new Notification ( payload . notification . title , payload . notification ) ;
69- }
70-
71- // Otherwise, we need to ask the user for permission
72- else if ( Notification . permission !== 'denied' ) {
73- const permission = await Notification . requestPermission ( ) ;
74- if ( permission === 'granted' ) {
75- new Notification ( payload . notification . title , payload . notification ) ;
76- }
77- }
78- } ) ;
7949 } else {
8050 await PushNotifications . removeAllListeners ( ) ;
8151 await PushNotifications . addListener ( 'registration' , onDeviceRegistration ) ;
0 commit comments