yodo1-mas-react-native-plugin
Version:
React Native plugin for Yodo1 MAS SDK
130 lines (129 loc) • 5.41 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.showRewardedAdsWithPlacementId = exports.showRewardedAds = exports.showRewardInterstitialAdsWithPlacementId = exports.showRewardInterstitialAds = exports.showNativeAds = exports.showInterstitialAdsWithPlacementId = exports.showInterstitialAds = exports.showBannerAds = exports.showAppOpenAdsWithPlacementId = exports.showAppOpenAds = exports.showAdExplainer = exports.setReward = exports.setGDPR = exports.setCOPPA = exports.setCCPA = exports.registerYodoAds = exports.hasReward = exports.closeNativeAd = exports.closeBannerAd = exports.ShowRewardGivenAlert = exports.NativeView = exports.CustomView = exports.BannerView = void 0;
var _reactNative = require("react-native");
const {
Yodo1MASAds
} = _reactNative.NativeModules;
const NativeView = exports.NativeView = (0, _reactNative.requireNativeComponent)('NativeView');
const BannerView = exports.BannerView = (0, _reactNative.requireNativeComponent)('BannerView');
const CustomView = exports.CustomView = (0, _reactNative.requireNativeComponent)('CustomView');
const hasReward = () => {
// Your code here to check if the user has earned a reward
// From Redux, AsyncStorage
return true;
};
exports.hasReward = hasReward;
const setReward = () => {
// Your code here to confirm that the user earned a reward
// Redux, AsyncStorage, etc...
};
exports.setReward = setReward;
const showAdExplainer = () => _reactNative.Alert.alert('You must watch the entire Ad to earn the reward!');
exports.showAdExplainer = showAdExplainer;
const ShowRewardGivenAlert = () => _reactNative.Alert.alert('Reward Added');
exports.ShowRewardGivenAlert = ShowRewardGivenAlert;
const handleYodoEvent = ({
value
}) => {
__DEV__ && console.log(`MAS Event: ${value}`);
switch (value) {
case 'onMasInitSuccessful':
break;
case 'onMasInitFailed':
setTimeout(() => Yodo1MASAds.initMasSdk(true, true, true), 5000);
break;
case 'reward-onRewardAdEarned':
setTimeout(() => hasReward() ? null : ShowRewardGivenAlert(), 5000);
setReward();
break;
case 'reward-onRewardAdLoaded':
setTimeout(() => hasReward() ? null : showAdExplainer(), 500);
break;
case 'reward-onRewardAdOpened':
setTimeout(() => hasReward() ? null : showAdExplainer(), 500);
break;
case 'reward-onRewardAdClosed':
setTimeout(() => hasReward() ? null : showAdExplainer(), 500);
break;
case 'reward-onRewardAdFailedToLoad':
setReward();
break;
case 'adRefresh':
break;
}
};
const registerYodoAds = () => {
const eventEmitter = new _reactNative.NativeEventEmitter(Yodo1MASAds);
const eventListener = eventEmitter.addListener('adEvent', handleYodoEvent);
Yodo1MASAds.initMasSdk(true, true, true);
return eventListener;
};
exports.registerYodoAds = registerYodoAds;
const showBannerAds = ref => {
const reactTag = (0, _reactNative.findNodeHandle)(ref);
Yodo1MASAds.showBannerAds(reactTag);
};
exports.showBannerAds = showBannerAds;
const showInterstitialAds = async () => {
Yodo1MASAds.showInterstitialAds();
};
exports.showInterstitialAds = showInterstitialAds;
const showInterstitialAdsWithPlacementId = async () => {
Yodo1MASAds.showInterstitialAdsWithPlacementId('InterstitialAdPlacementId');
};
exports.showInterstitialAdsWithPlacementId = showInterstitialAdsWithPlacementId;
const showRewardedAds = async () => {
Yodo1MASAds.showRewardedAds();
};
exports.showRewardedAds = showRewardedAds;
const showRewardedAdsWithPlacementId = async () => {
Yodo1MASAds.showRewardedAdsWithPlacementId('RewardedAdPlacementId');
};
exports.showRewardedAdsWithPlacementId = showRewardedAdsWithPlacementId;
const showAppOpenAds = async () => {
Yodo1MASAds.showAppOpenAds();
};
exports.showAppOpenAds = showAppOpenAds;
const showAppOpenAdsWithPlacementId = async () => {
Yodo1MASAds.showAppOpenAdsWithPlacementId('AppOpenAdPlacementId');
};
exports.showAppOpenAdsWithPlacementId = showAppOpenAdsWithPlacementId;
const showRewardInterstitialAds = async () => {
Yodo1MASAds.showRewardInterstitialAds();
};
exports.showRewardInterstitialAds = showRewardInterstitialAds;
const showRewardInterstitialAdsWithPlacementId = async () => {
Yodo1MASAds.showRewardInterstitialAdsWithPlacementId('RewardInterstitialAdPlacementId');
};
exports.showRewardInterstitialAdsWithPlacementId = showRewardInterstitialAdsWithPlacementId;
const showNativeAds = async ref => {
const reactTag = (0, _reactNative.findNodeHandle)(ref);
Yodo1MASAds.showNativeAds(reactTag);
};
exports.showNativeAds = showNativeAds;
const setCCPA = async () => {
Yodo1MASAds.setCCPA(true);
};
exports.setCCPA = setCCPA;
const setCOPPA = async () => {
Yodo1MASAds.setCOPPA(true);
};
exports.setCOPPA = setCOPPA;
const setGDPR = async () => {
Yodo1MASAds.setGDPR(true);
};
exports.setGDPR = setGDPR;
const closeBannerAd = async ref => {
const reactTag = (0, _reactNative.findNodeHandle)(ref);
_reactNative.Platform.OS === 'ios' ? Yodo1MASAds.closeBannerAd(reactTag) : Yodo1MASAds.closeBannerAd();
};
exports.closeBannerAd = closeBannerAd;
const closeNativeAd = async ref => {
const reactTag = (0, _reactNative.findNodeHandle)(ref);
_reactNative.Platform.OS === 'ios' ? Yodo1MASAds.closeNativeAd(reactTag) : Yodo1MASAds.closeNativeAd();
};
exports.closeNativeAd = closeNativeAd;
//# sourceMappingURL=index.js.map