ref: Use platformId global instead of calling into native layer getPlatform #199
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uses the
window.cordova.platformId
global that's present on Cordova instead of calling into our native bridge and needing to await a promise to determine what platform it is being run on. This results in way cleaner code. Thus, this also removes the need to call into the native bridge (which we don't have a native module for, so it will throw an error that we catch) on browser and other platforms.This
platformId
global has been there for 7 years or so, so it should be safe to use, but seems to not be documented anywhere.This PR refactors how the native bridge checks whether the native SDK, native transport, and native scope sync is ready or not. We do this by storing which platform each feature is supported in the native wrapper:
SUPPORTS_NATIVE_TRANSPORT
,SUPPORTS_NATIVE_SCOPE_SYNC
,SUPPORTS_NATIVE_SDK
.Tests on the native wrapper are also updated to reflect the changes here.