@wscsports/blaze-rtn-gam-ads
Version:
WSC Sports Blaze GAM Ads component for React Native
40 lines • 1.24 kB
JavaScript
import { RegisterGlobalEvents } from "./utils/RegisterGlobalEvents";
export class BlazeGlobalDelegateHelper {
static registerDelegate(delegate) {
BlazeGlobalDelegateHelper.onGAMAdEvent(delegate?.onGAMAdEvent);
BlazeGlobalDelegateHelper.onGAMAdError(delegate?.onGAMAdError);
}
static onGAMAdEvent(callback) {
const eventName = 'BlazeGAM.onAdEvent';
if (callback) {
RegisterGlobalEvents.createEventSubscription(eventName, data => {
try {
const eventType = data['eventType'];
callback({
eventType
});
} catch (e) {
console.error('onGAMAdEvent', e);
}
});
} else {
RegisterGlobalEvents.cancelEventSubscription(eventName);
}
}
static onGAMAdError(callback) {
const eventName = 'BlazeGAM.onAdError';
if (callback) {
RegisterGlobalEvents.createEventSubscription(eventName, data => {
try {
const errorMessage = data['errorMessage'];
callback(errorMessage);
} catch (e) {
console.error('onGAMAdError', e);
}
});
} else {
RegisterGlobalEvents.cancelEventSubscription(eventName);
}
}
}
//# sourceMappingURL=BlazeGAMDelegate.js.map