1
- import firebase from " firebase/app" ;
2
- import " firebase/messaging" ;
1
+ import firebase from ' firebase/app' ;
2
+ import ' firebase/messaging' ;
3
3
4
4
// See: https://github.com/microsoft/TypeScript/issues/14877
5
5
/** @type {ServiceWorkerGlobalScope } */
@@ -10,8 +10,8 @@ function initInSw() {
10
10
// Give the service worker access to Firebase Messaging.
11
11
// Note that you can only use Firebase Messaging here. Other Firebase libraries
12
12
// are not available in the service worker.
13
- importScripts ( 'https://www.gstatic.com/firebasejs/9.2.0 /firebase-app.js' ) ;
14
- importScripts ( 'https://www.gstatic.com/firebasejs/9.2.0 /firebase-messaging.js' ) ;
13
+ importScripts ( 'https://www.gstatic.com/firebasejs/8.10.1 /firebase-app.js' ) ;
14
+ importScripts ( 'https://www.gstatic.com/firebasejs/8.10.1 /firebase-messaging.js' ) ;
15
15
16
16
// Initialize the Firebase app in the service worker by passing in
17
17
// your app's Firebase config object.
@@ -38,16 +38,18 @@ function onBackgroundMessage() {
38
38
39
39
// [START messaging_on_background_message]
40
40
messaging . onBackgroundMessage ( ( payload ) => {
41
- console . log ( '[firebase-messaging-sw.js] Received background message ' , payload ) ;
41
+ console . log (
42
+ '[firebase-messaging-sw.js] Received background message ' ,
43
+ payload
44
+ ) ;
42
45
// Customize notification here
43
46
const notificationTitle = 'Background Message Title' ;
44
47
const notificationOptions = {
45
48
body : 'Background Message body.' ,
46
49
icon : '/firebase-logo.png'
47
50
} ;
48
-
49
- self . registration . showNotification ( notificationTitle ,
50
- notificationOptions ) ;
51
+
52
+ self . registration . showNotification ( notificationTitle , notificationOptions ) ;
51
53
} ) ;
52
54
// [END messaging_on_background_message]
53
55
}
0 commit comments