@@ -66,7 +66,7 @@ class PlaygamaPlatformBridge extends PlatformBridgeBase {
6666
6767 // player
6868 get isPlayerAuthorizationSupported ( ) {
69- return true
69+ return this . #isPlayerAuthorizationSupported
7070 }
7171
7272 // payments
@@ -76,8 +76,12 @@ class PlaygamaPlatformBridge extends PlatformBridgeBase {
7676
7777 _isAdvancedBannersSupported = true
7878
79+ #isCloudSaveSupported = true
80+
7981 #isPaymentsSupported = true
8082
83+ #isPlayerAuthorizationSupported = true
84+
8185 initialize ( ) {
8286 if ( this . _isInitialized ) {
8387 return Promise . resolve ( )
@@ -142,20 +146,21 @@ class PlaygamaPlatformBridge extends PlatformBridgeBase {
142146 }
143147 } )
144148
145- Promise . all ( [
146- this . #getPlayer( ) ,
147- this . _platformSdk . platformService ?. isReady ?? Promise . resolve ( ) ,
148- ] ) . then ( ( ) => {
149- if ( this . _platformSdk . platformService ?. getIsPaymentsSupported ) {
150- this . #isPaymentsSupported = this . _platformSdk . platformService . getIsPaymentsSupported ( )
151- }
152- this . _isInitialized = true
153- this . _resolvePromiseDecorator ( ACTION_NAME . INITIALIZE )
154- } )
149+ const platformReadyPromise = this . _platformSdk . platformService ?. isReady ?? Promise . resolve ( )
150+ platformReadyPromise
151+ . then ( ( ) => {
152+ this . #resolveSupportedFeatures( )
155153
156- if ( this . _platformSdk . platformService ?. getAdditionalParams ) {
157- this . _additionalData = this . _platformSdk . platformService . getAdditionalParams ( ) || { }
158- }
154+ if ( this . _platformSdk . platformService ?. getAdditionalParams ) {
155+ this . _additionalData = this . _platformSdk . platformService . getAdditionalParams ( ) || { }
156+ }
157+
158+ return this . #getPlayer( )
159+ } )
160+ . then ( ( ) => {
161+ this . _isInitialized = true
162+ this . _resolvePromiseDecorator ( ACTION_NAME . INITIALIZE )
163+ } )
159164 } )
160165 } )
161166 }
@@ -179,22 +184,26 @@ class PlaygamaPlatformBridge extends PlatformBridgeBase {
179184 // storage
180185 isStorageSupported ( storageType ) {
181186 if ( storageType === STORAGE_TYPE . PLATFORM_INTERNAL ) {
182- return true
187+ return this . #isCloudSaveSupported
183188 }
184189
185190 return super . isStorageSupported ( storageType )
186191 }
187192
188193 isStorageAvailable ( storageType ) {
189194 if ( storageType === STORAGE_TYPE . PLATFORM_INTERNAL ) {
190- return this . _isPlayerAuthorized
195+ return this . #isCloudSaveSupported && this . _isPlayerAuthorized
191196 }
192197
193198 return super . isStorageAvailable ( storageType )
194199 }
195200
196201 getDataFromStorage ( key , storageType , tryParseJson ) {
197202 if ( storageType === STORAGE_TYPE . PLATFORM_INTERNAL ) {
203+ if ( ! this . #isCloudSaveSupported) {
204+ return Promise . reject ( ERROR . STORAGE_NOT_SUPPORTED )
205+ }
206+
198207 if ( ! this . _isPlayerAuthorized ) {
199208 return Promise . reject ( )
200209 }
@@ -208,6 +217,10 @@ class PlaygamaPlatformBridge extends PlatformBridgeBase {
208217 setDataToStorage ( key , value , storageType ) {
209218 switch ( storageType ) {
210219 case STORAGE_TYPE . PLATFORM_INTERNAL : {
220+ if ( ! this . #isCloudSaveSupported) {
221+ return Promise . reject ( ERROR . STORAGE_NOT_SUPPORTED )
222+ }
223+
211224 if ( ! this . _isPlayerAuthorized ) {
212225 return Promise . reject ( )
213226 }
@@ -257,6 +270,10 @@ class PlaygamaPlatformBridge extends PlatformBridgeBase {
257270 deleteDataFromStorage ( key , storageType ) {
258271 switch ( storageType ) {
259272 case STORAGE_TYPE . PLATFORM_INTERNAL : {
273+ if ( ! this . #isCloudSaveSupported) {
274+ return Promise . reject ( ERROR . STORAGE_NOT_SUPPORTED )
275+ }
276+
260277 return new Promise ( ( resolve , reject ) => {
261278 const data = this . _platformStorageCachedData !== null
262279 ? { ...this . _platformStorageCachedData }
@@ -321,6 +338,10 @@ class PlaygamaPlatformBridge extends PlatformBridgeBase {
321338 }
322339
323340 authorizePlayer ( options ) {
341+ if ( ! this . #isPlayerAuthorizationSupported) {
342+ return Promise . reject ( )
343+ }
344+
324345 let promiseDecorator = this . _getPromiseDecorator ( ACTION_NAME . AUTHORIZE_PLAYER )
325346 if ( ! promiseDecorator ) {
326347 promiseDecorator = this . _createPromiseDecorator ( ACTION_NAME . AUTHORIZE_PLAYER )
@@ -349,6 +370,10 @@ class PlaygamaPlatformBridge extends PlatformBridgeBase {
349370
350371 // payments
351372 paymentsPurchase ( id , options ) {
373+ if ( ! this . isPaymentsSupported ) {
374+ return Promise . reject ( )
375+ }
376+
352377 const product = this . _paymentsGetProductPlatformData ( id )
353378 if ( ! product ) {
354379 return Promise . reject ( )
@@ -469,6 +494,11 @@ class PlaygamaPlatformBridge extends PlatformBridgeBase {
469494 }
470495
471496 #getPlayer( ) {
497+ if ( ! this . #isPlayerAuthorizationSupported) {
498+ this . _playerApplyGuestData ( )
499+ return Promise . resolve ( )
500+ }
501+
472502 return new Promise ( ( resolve ) => {
473503 this . _platformSdk . userService . getUser ( )
474504 . then ( ( player ) => {
@@ -478,8 +508,12 @@ class PlaygamaPlatformBridge extends PlatformBridgeBase {
478508 this . _playerName = player . name
479509 this . _playerPhotos = player . photos
480510 this . _playerExtra = player
481- this . _defaultStorageType = STORAGE_TYPE . PLATFORM_INTERNAL
482- return this . #getDataFromPlatformStorage( [ ] )
511+ if ( this . #isCloudSaveSupported) {
512+ this . _defaultStorageType = STORAGE_TYPE . PLATFORM_INTERNAL
513+ return this . #getDataFromPlatformStorage( [ ] )
514+ }
515+
516+ return Promise . resolve ( )
483517 }
484518
485519 this . _playerApplyGuestData ( )
@@ -501,6 +535,20 @@ class PlaygamaPlatformBridge extends PlatformBridgeBase {
501535
502536 return getKeysFromObject ( key , this . _platformStorageCachedData , tryParseJson )
503537 }
538+
539+ #resolveSupportedFeatures( ) {
540+ if ( this . _platformSdk . platformService ?. getIsPlayerAuthorizationSupported ) {
541+ this . #isPlayerAuthorizationSupported = this . _platformSdk . platformService . getIsPlayerAuthorizationSupported ( )
542+ }
543+
544+ if ( this . _platformSdk . platformService ?. getIsCloudSaveSupported ) {
545+ this . #isCloudSaveSupported = this . _platformSdk . platformService . getIsCloudSaveSupported ( )
546+ }
547+
548+ if ( this . _platformSdk . platformService ?. getIsPaymentsSupported ) {
549+ this . #isPaymentsSupported = this . _platformSdk . platformService . getIsPaymentsSupported ( )
550+ }
551+ }
504552}
505553
506554export default PlaygamaPlatformBridge
0 commit comments