File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -21,21 +21,25 @@ try {
2121 }
2222
2323 onBackgroundMessage ( messaging , ( payload ) => {
24- const notificationTitle = payload . notification . title
24+ const data = payload . data || { }
25+ const notification = payload . notification || { }
26+
27+ const notificationTitle = data . title || notification . title
2528 let notificationOptions = {
26- body : payload . notification . body || "" ,
29+ body : data . body || notification . body || "" ,
2730 }
28- if ( payload . data . image ) {
29- notificationOptions [ "icon" ] = payload . data . image
31+
32+ if ( data . image ) {
33+ notificationOptions [ "icon" ] = data . image
3034 }
3135
32- if ( payload . data . creation ) {
33- notificationOptions [ "timestamp" ] = payload . data . creation
36+ if ( data . creation ) {
37+ notificationOptions [ "timestamp" ] = data . creation
3438 }
35- let url = `${ payload . data . base_url } /raven/channel/${ payload . data . channel_id } `
39+ let url = `${ data . base_url } /raven/channel/${ data . channel_id } `
3640
37- if ( payload . data . message_url ) {
38- url = payload . data . message_url
41+ if ( data . message_url ) {
42+ url = data . message_url
3943 }
4044
4145 if ( isChrome ( ) ) {
6872
6973self . skipWaiting ( )
7074clientsClaim ( )
71- console . log ( "Service Worker Initialized" )
75+ console . log ( "Service Worker Initialized" )
You can’t perform that action at this time.
0 commit comments