@@ -22,40 +22,19 @@ OneSignal.push(function () {
2222 } ) ;
2323} ) ;
2424
25- OneSignal . push ( [
26- 'getNotificationPermission' ,
27- ( permission ) => {
28- const isPushSupported = OneSignal . isPushNotificationsSupported ( ) ;
29- if ( isPushSupported && permission === 'default' ) {
30- // document.getElementById('notification-bar').hidden = false;
31- }
32- OneSignal . on ( 'notificationPermissionChange' , ( ) => {
33- // document.getElementById('notification-bar').hidden = true;
34- } ) ;
35- } ,
36- ] ) ;
37-
38- // function registerNotifier() {
39- // const hideNotificationBar =
40- // localStorage.getItem('notificationBar') === 'hide';
41- // if (!hideNotificationBar) {
42- // const bar = document.getElementById('notification-bar');
43-
44- // const closeBar = () => {
45- // bar.hidden = true;
46- // localStorage.setItem('notificationBar', 'hide');
47- // };
48-
49- // bar.hidden = false;
50- // bar.querySelector('button.close').addEventListener('click', closeBar);
51-
52- // bar.querySelector('.btn.btn-link').addEventListener('click', async () => {
53- // await Notification.requestPermission();
54- // closeBar();
55- // });
56- // }
57- // }
58-
5925if ( 'serviceWorker' in navigator ) {
60- navigator . serviceWorker . register ( '/OneSignalSDKWorker.js' ) ;
26+ navigator . serviceWorker . register ( '/OneSignalSDKWorker.js' ) . then ( ( ) => {
27+ OneSignal . push ( [
28+ 'getNotificationPermission' ,
29+ ( permission ) => {
30+ const isPushSupported = OneSignal . isPushNotificationsSupported ( ) ;
31+ if ( isPushSupported && permission === 'default' ) {
32+ document . getElementById ( 'notification-bar' ) . hidden = false ;
33+ }
34+ OneSignal . on ( 'notificationPermissionChange' , ( ) => {
35+ document . getElementById ( 'notification-bar' ) . hidden = true ;
36+ } ) ;
37+ } ,
38+ ] ) ;
39+ } ) ;
6140}
0 commit comments