File tree 3 files changed +12
-8
lines changed
3 files changed +12
-8
lines changed Original file line number Diff line number Diff line change 1
1
import doRequest from './do-request' ;
2
+ import { version as sdkVersion } from '../package.json' ;
2
3
3
4
const INTERESTS_REGEX = new RegExp ( '^(_|\\-|=|@|,|\\.|;|[A-Z]|[a-z]|[0-9])*$' ) ;
4
5
const MAX_INTEREST_LENGTH = 164 ;
@@ -14,7 +15,7 @@ export const RegistrationState = Object.freeze({
14
15
} ) ;
15
16
16
17
export default class BaseClient {
17
- constructor ( config ) { }
18
+ constructor ( _ ) { }
18
19
19
20
async getDeviceId ( ) {
20
21
await this . _resolveSDKState ( ) ;
@@ -195,7 +196,6 @@ export default class BaseClient {
195
196
const response = await doRequest ( options ) ;
196
197
return response . id ;
197
198
}
198
-
199
199
}
200
200
201
201
function validateInterestName ( interest ) {
Original file line number Diff line number Diff line change @@ -79,7 +79,7 @@ export class SafariClient extends BaseClient {
79
79
}
80
80
81
81
_requestPermission ( ) {
82
- return new Promise ( ( resolve ) => {
82
+ return new Promise ( resolve => {
83
83
window . safari . pushNotification . requestPermission (
84
84
__url ,
85
85
__pushId ,
@@ -94,7 +94,7 @@ export class SafariClient extends BaseClient {
94
94
return this ;
95
95
}
96
96
97
- let { deviceToken , permission } = getPermission ( __pushId ) ;
97
+ let { permission } = getPermission ( __pushId ) ;
98
98
99
99
if ( permission === 'default' ) {
100
100
console . debug ( 'permission is default, requesting permission' ) ;
@@ -209,6 +209,10 @@ export class SafariClient extends BaseClient {
209
209
}
210
210
}
211
211
212
+ function isSupportedBrowser ( ) {
213
+ return isSupportedVersion ( ) ;
214
+ }
215
+
212
216
function isSupportedVersion ( ) {
213
217
return 'safari' in window && 'pushNotification' in window . safari ;
214
218
}
Original file line number Diff line number Diff line change @@ -261,8 +261,8 @@ export class WebPushClient extends BaseClient {
261
261
262
262
async _clearPushToken ( ) {
263
263
return navigator . serviceWorker . ready
264
- . then ( ( reg ) => reg . pushManager . getSubscription ( ) )
265
- . then ( ( sub ) => {
264
+ . then ( reg => reg . pushManager . getSubscription ( ) )
265
+ . then ( sub => {
266
266
if ( sub ) sub . unsubscribe ( ) ;
267
267
} ) ;
268
268
}
@@ -289,7 +289,7 @@ async function getServiceWorkerRegistration() {
289
289
function getWebPushToken ( swReg ) {
290
290
return swReg . pushManager
291
291
. getSubscription ( )
292
- . then ( ( sub ) => ( ! sub ? null : encodeSubscription ( sub ) ) ) ;
292
+ . then ( sub => ( ! sub ? null : encodeSubscription ( sub ) ) ) ;
293
293
}
294
294
295
295
function encodeSubscription ( sub ) {
@@ -300,7 +300,7 @@ function urlBase64ToUInt8Array(base64String) {
300
300
const padding = '=' . repeat ( ( 4 - ( base64String . length % 4 ) ) % 4 ) ;
301
301
const base64 = ( base64String + padding ) . replace ( / - / g, '+' ) . replace ( / _ / g, '/' ) ;
302
302
const rawData = window . atob ( base64 ) ;
303
- return Uint8Array . from ( [ ...rawData ] . map ( ( char ) => char . charCodeAt ( 0 ) ) ) ;
303
+ return Uint8Array . from ( [ ...rawData ] . map ( char => char . charCodeAt ( 0 ) ) ) ;
304
304
}
305
305
306
306
/**
You can’t perform that action at this time.
0 commit comments