@wscsports/blaze-rtn-gam-ads
Version:
WSC Sports Blaze GAM Ads component for React Native
49 lines (43 loc) • 1.51 kB
JavaScript
import { NativeModules } from 'react-native';
import { BlazeCustomNativeAdsDelegateHelper } from './BlazeGAMCustomNativeAdsDelegate';
import { BlazeBannerAdsDelegateHelper } from './BlazeGAMBannerAdsDelegate';
/**
* This Model is being sent to the native side.
*/
const {
RTNBlazeGAM
} = NativeModules;
const BlazeGAMNativeModule = RTNBlazeGAM;
// This wrapper is hiding the internal interface that works with the native module, and serves as additional layer to add custom logic.
class BlazeGAMWrapper {
enableCustomNativeAds(options) {
BlazeGAMNativeModule.enableCustomNativeAds({
defaultAdConfig: options.defaultAdConfig
});
BlazeCustomNativeAdsDelegateHelper.registerDelegate(options.delegate);
}
disableCustomNativeAds() {
BlazeGAMNativeModule.disableCustomNativeAds();
BlazeCustomNativeAdsDelegateHelper.registerDelegate(null);
}
enableBannerAds(options) {
BlazeGAMNativeModule.enableBannerAds();
BlazeBannerAdsDelegateHelper.registerDelegate(options.delegate);
}
disableBannerAds() {
BlazeGAMNativeModule.disableBannerAds();
BlazeBannerAdsDelegateHelper.registerDelegate(null);
}
// Singleton instance
// Private constructor for singleton
constructor() {}
// Method to get singleton instance
static getInstance() {
if (!this.instance) {
this.instance = new BlazeGAMWrapper();
}
return this.instance;
}
}
export const BlazeGAM = BlazeGAMWrapper.getInstance();
//# sourceMappingURL=NativeBlazeGAM.js.map