1+ import doRequest from './do-request' ;
12import BaseClient from './base-client' ;
23import { version as sdkVersion } from '../package.json' ;
34import { RegistrationState } from './base-client' ;
45
56const __url = 'https://localhost:8080' ;
6- const __pushId = 'web.io.lees.safari-push' ;
7-
87const platform = 'safari' ;
98
109export class SafariClient extends BaseClient {
@@ -20,7 +19,8 @@ export class SafariClient extends BaseClient {
2019 }
2120
2221 async _init ( ) {
23- this . _websitePushId = await this . _fetchWebsitePushId ( ) ;
22+ let { websitePushId } = await this . _fetchWebsitePushId ( ) ;
23+ this . _websitePushId = websitePushId ;
2424 this . _serviceUrl = __url ;
2525
2626 if ( this . _deviceId !== null ) {
@@ -66,7 +66,7 @@ export class SafariClient extends BaseClient {
6666 window . safari . pushNotification . requestPermission (
6767 this . _serviceUrl ,
6868 this . _websitePushId ,
69- { userID : 'abcdef' } ,
69+ { } ,
7070 resolve
7171 ) ;
7272 } ) ;
@@ -153,11 +153,14 @@ export class SafariClient extends BaseClient {
153153 }
154154
155155 _fetchWebsitePushId ( ) {
156- return new Promise ( resolve => {
157- // TODO temporary
158- resolve ( __pushId ) ;
159- } ) ;
156+ const path = `${ this . _baseURL } /device_api/v1/instances/${ encodeURIComponent (
157+ this . instanceId
158+ ) } /safari-website-push-id`;
159+
160+ const options = { method : 'GET' , path } ;
161+ return doRequest ( options ) ;
160162 }
163+
161164 _isSupportedBrowser ( ) {
162165 return 'safari' in window && 'pushNotification' in window . safari ;
163166 }
0 commit comments