@wscsports/blaze-rtn-sdk
Version:
WSC Sports Blaze SDK component for React Native
92 lines (88 loc) • 3.4 kB
JavaScript
import { NativeModules } from 'react-native';
import { BlazeGlobalDelegateHelper } from './classes/global-delegate';
import { BlazeEntryPointDelegateHelper } from './classes/entry-point-delegate';
import { mapToBlazeErrorOrRethrow } from './interfaces/blaze-error.interface';
const {
RTNBlazeSdk
} = NativeModules;
const BlazeSDKNativeModule = RTNBlazeSdk;
// This wrapper is hiding the internal interface that works with the native module, and serves as additional layer to add custom logic.
class BlazeSdkWrapper {
init(options) {
this.setEntryPointDelegate(options.playerEntryPointDelegate);
this.setGlobalDelegate(options.globalDelegate);
return BlazeSDKNativeModule.init(options).catch(mapToBlazeErrorOrRethrow);
}
isInitialized() {
return BlazeSDKNativeModule.isInitialized();
}
playStory(options) {
return BlazeSDKNativeModule.playStory(options).catch(mapToBlazeErrorOrRethrow);
}
prepareStories(options) {
return BlazeSDKNativeModule.prepareStories(options).catch(mapToBlazeErrorOrRethrow);
}
playStories(options) {
return BlazeSDKNativeModule.playStories(options).catch(mapToBlazeErrorOrRethrow);
}
playMoment(options) {
return BlazeSDKNativeModule.playMoment(options).catch(mapToBlazeErrorOrRethrow);
}
prepareMoments(options) {
return BlazeSDKNativeModule.prepareMoments(options).catch(mapToBlazeErrorOrRethrow);
}
playMoments(options) {
return BlazeSDKNativeModule.playMoments(options).catch(mapToBlazeErrorOrRethrow);
}
playVideo(options) {
return BlazeSDKNativeModule.playVideo(options).catch(mapToBlazeErrorOrRethrow);
}
prepareVideos(options) {
return BlazeSDKNativeModule.prepareVideos(options).catch(mapToBlazeErrorOrRethrow);
}
playVideos(options) {
return BlazeSDKNativeModule.playVideos(options).catch(mapToBlazeErrorOrRethrow);
}
dismissPlayer() {
return BlazeSDKNativeModule.dismissPlayer();
}
setExternalUserId(externalUserId) {
return BlazeSDKNativeModule.setExternalUserId(externalUserId).catch(mapToBlazeErrorOrRethrow);
}
setDoNotTrack(doNotTrackUser) {
return BlazeSDKNativeModule.setDoNotTrack(doNotTrackUser);
}
handleUniversalLink(link) {
return BlazeSDKNativeModule.handleUniversalLink(link).catch(mapToBlazeErrorOrRethrow);
}
canHandleUniversalLink(link) {
return BlazeSDKNativeModule.canHandleUniversalLink(link);
}
updateGeoRestriction(geoLocation) {
return BlazeSDKNativeModule.updateGeoRestriction(geoLocation).catch(mapToBlazeErrorOrRethrow);
}
setGlobalDelegate(globalDelegate) {
BlazeGlobalDelegateHelper.registerGlobalDelegate(globalDelegate);
}
setEntryPointDelegate(playerEntryPointDelegate) {
BlazeEntryPointDelegateHelper.registerEntryPointDelegate(playerEntryPointDelegate);
}
canHandlePushNotification(payload) {
return BlazeSDKNativeModule.canHandlePushNotification(payload);
}
handleNotificationPayload(payload) {
return BlazeSDKNativeModule.handleNotificationPayload(payload).catch(mapToBlazeErrorOrRethrow);
}
// Singleton instance
// Private constructor for singleton
constructor() {}
// Method to get singleton instance
static getInstance() {
if (!this.instance) {
this.instance = new BlazeSdkWrapper();
}
return this.instance;
}
}
export const BlazeSDK = BlazeSdkWrapper.getInstance();
//# sourceMappingURL=NativeBlazeSdk.js.map