UNPKG

@azerion/bluestack-sdk-react-native

Version:

BlueStack provides functionalities for monetizing your mobile application: from premium sales with rich media, video and innovative formats, it facilitates inserting native mobile ads as well all standard display formats. BlueStack SDK is a library that a

78 lines (76 loc) 3.11 kB
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; } function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; } function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); } import { findNodeHandle, UIManager } from 'react-native'; import React from 'react'; import { BannerModuleView } from './BannerViewManager'; import logger from '../Utils/Logger'; export class BannerView extends React.Component { constructor(props) { super(props); _defineProperty(this, "_preferenceJSON", '{}'); _defineProperty(this, "_shouldAutoLoadWhenReady", false); this.state = { visible: true }; if (this.props.shouldLoadWhenReady != null) { this._shouldAutoLoadWhenReady = this.props.shouldLoadWhenReady; } if (this.props.preference != null && this._preferenceJSON === '{}') { this._preferenceJSON = this.props.preference.getPreferenceJSON(); } else { this._preferenceJSON = '{}'; } } load(bsPreference) { if (this._shouldAutoLoadWhenReady) { logger.log('Banner load call is not required when shouldLoadWhenReady is true'); } if (bsPreference != null) { this._preferenceJSON = bsPreference.getPreferenceJSON(); } else { this._preferenceJSON = '{}'; } this.loadWithPreferenceJSON(this._preferenceJSON); } loadWithPreferenceJSON(preferenceJSON) { logger.log('Loading Banner ad with preference: ' + preferenceJSON); UIManager.dispatchViewManagerCommand(findNodeHandle(this), 'create', [preferenceJSON]); } destroy() { UIManager.dispatchViewManagerCommand(findNodeHandle(this), 'destroy', []); } toggleRefresh(state = false) { UIManager.dispatchViewManagerCommand(findNodeHandle(this), 'refresh', [state]); } hide() { this.setState({ visible: false }); } show() { this.setState({ visible: true }); } // private handleBannerAdLoadCalled(): void { // logger.log('handleBannerAdLoadCalled: onBannerAdLoadCalled'); // //reset shouldLoadNow for next call // this.setState({ shouldLoadNow: false }); // } render() { return /*#__PURE__*/React.createElement(BannerModuleView, { shouldLoadWhenReady: this._shouldAutoLoadWhenReady, visible: this.state.visible, type: this.props.type, placementId: this.props.placementId, preference: this._preferenceJSON, onBannerAdLoaded: this.props.onAdLoaded, onBannerAdFailedToLoad: this.props.onAdFailedToLoad, onBannerAdRefreshed: this.props.onAdRefreshed, onBannerAdFailedToRefresh: this.props.onAdFailedToRefresh, onBannerAdClicked: this.props.onAdClicked }); } } //# sourceMappingURL=BannerView.js.map