Estoy intentando agregar Admob Interstitial en react native, pero quiero que el anuncio aparezca sin necesidad de utilizarlo con un evento de un button (onPress), es posible hacer esto y también he tratado que el anuncio se ejecutarte cada cierto tiempo, he pensado utilizar setTimeOut(funcion, 1000), no se si es factible utilizarlo porque quiero que el anuncio aparecezca cada cierto tiempo, mientras la aplicación este ejecutandose.
no se que podrían recomendarme
interstitialDidClose() {
AdMobInterstitial.requestAdAsync((error) => error && log(error));
}
componentDidMount() {
AdMintroducir el código aquíobRewarded.setTestDeviceID([Config.AdMob.deviceID]);
AdMobRewarded.setAdUnitID('ca-app-pub-3940256099942544/5224354917');
AdMobRewarded.addEventListener('rewarded', reward =>
console.log('AdMobRewarded => rewarded', reward),
);
AdMobRewarded.addEventListener('adLoaded', () =>
console.log('AdMobRewarded => adLoaded'),
);
AdMobRewarded.addEventListener('adFailedToLoad', error =>
console.warn(error),
);
AdMobRewarded.addEventListener('adOpened', () =>
console.log('AdMobRewarded => adOpened'),
);
AdMobRewarded.addEventListener('videoStarted', () =>
console.log('AdMobRewarded => videoStarted'),
);
AdMobRewarded.addEventListener('adClosed', () => {
console.log('AdMobRewarded => adClosed');
AdMobRewarded.requestAdAsync().catch(error => console.warn(error));
});
AdMobRewarded.addEventListener('adLeftApplication', () =>
console.log('AdMobRewarded => adLeftApplication'),
);
AdMobRewarded.requestAdAsync().catch(error => console.warn(error));
AdMobInterstitial.setTestDeviceID([Config.AdMob.deviceID]);
AdMobInterstitial.setAdUnitID('ca-app-pub-3940256099942544/1033173712');
AdMobInterstitial.addEventListener('adLoaded', () =>
console.log('AdMobInterstitial adLoaded'),
);
AdMobInterstitial.addEventListener('adFailedToLoad', error =>
console.warn(error),
);
AdMobInterstitial.addEventListener('adOpened', () =>
console.log('AdMobInterstitial => adOpened'),
);
AdMobInterstitial.addEventListener('adClosed', () => {
console.log('AdMobInterstitial => adClosed');
AdMobInterstitial.requestAdAsync().catch(error => console.warn(error));
});
AdMobInterstitial.addEventListener('adLeftApplication', () =>
console.log('AdMobInterstitial => adLeftApplication'),
);
AdMobInterstitial.requestAdAsync().catch(error => console.warn(error));
}
componentWillUnmount() {
AdMobRewarded.removeAllListeners();
AdMobInterstitial.removeAllListeners();
}
showRewarded() {
AdMobRewarded.showAdAsync().catch(error => console.warn(error));
}
showInterstitial() {
AdMobInterstitial.showAdAsync().catch(error => console.warn(error))
}
render() {
return (
<Button
title="Show Interstitial and preload next"
onPress={this.showInterstitial}
/>
)
}