Support plugin https://boosty.to/maximnara
npm i cordova-plugin-yandex-ads --save
All methods support optional onSuccess
and onFailure
parameters
import * as YandexAds from 'cordova-plugin-yandex-ads/www/yandexads';
await YandexAds.init({
rewardedBlockId: 'YOUR_REWARDER_BLOCK_ID',
interstitialBlockId: 'YOUR_INTERSTITIAL_ID',
bannerBlockId: 'YOOUR_BANNER_ID',
openAppBlockId: 'YOUR_OPEN_APP_ADS_ID',
options: { // This is for banner ads
bannerAtTop: true, // Show banner on top of screen, otherwise on bottom
bannerSize: { width: 468, height: 100 }, // Your banner size
// You can skip bannerSize option and width will be as big as possible
},
});
Call this on every app launch. More info: https://yandex.ru/dev/mobile-ads/doc/android/quick-start/gdpr-about.html
YandexAds.setUserConsent(true);
rewarded.mp4
YandexAds.loadRewardedVideo({
onSuccess: function () {
},
onFailure: function () {
},
});
YandexAds.showRewardedVideo();
interstitial.mp4
Must be called before showInterstitial
YandexAds.loadInterstitial();
YandexAds.showInterstitial();
app.open.mp4
Must be called before showOpenAppAds
YandexAds.loadOpenAppAds();
YandexAds.showOpenAppAds();
Must be called before showBanner
YandexAds.loadBanner();
YandexAds.showBanner();
If you set banner size your banner will render in container, that will move content container (web view).
So calling loadBanner
will lead to web view jumps. To fix that use reloadBanner
method that will save container for banner.
So while banner loading empty container avoid web view jumps.
YandexAds.reloadBanner();
YandexAds.hideBanner();
Also you can find them here
{
interstitial: {
loaded: 'interstitialDidLoad',
failedToLoad: 'interstitialFailedToLoad',
shown: 'interstitialDidShow',
failedToShow: 'interstitialDidFailToShowWithError',
dismissed: 'interstitialDidDismiss',
clicked: 'interstitialDidClick',
impression: 'interstitialDidTrackImpressionWith',
},
rewarded: {
loaded: 'rewardedDidLoad',
failedToLoad: 'rewardedFailedToLoad',
rewarded: 'rewardedDidReward',
shown: 'rewardedDidShow',
failedToShow: 'rewardedDidFailToShowWithError',
dismissed: 'rewardedDidDismiss',
clicked: 'rewardedDidClick',
impression: 'rewardedDidTrackImpressionWith',
},
openAppAds: {
loaded: 'appOpenDidLoad',
failedToLoad: 'appOpenFailedToLoad',
shown: 'appOpenDidShow',
failedToShow: 'appOpenDidFailToShowWithError',
dismissed: 'appOpenDidDismiss',
clicked: 'appOpenDidClick',
impression: 'appOpenDidTrackImpressionWith',
},
banner: {
loaded: 'bannerDidLoad',
failedToLoad: 'bannerFailedToLoad',
clicked: 'bannerDidClick',
impression: 'bannerDidTrackImpressionWith',
leftApplication: 'bannerWillLeaveApplication',
}
}
Here we start listen ad loaded event, when it is fired we call showOpenAppAds
method.
window.addEventListener(YandexAds.events.openAppAds.loaded, async () => {
await YandexAds.showOpenAppAds();
});
iOS
Add this to your Info.plist
Please check official documentation in case of some breaking changes
<key>SKAdNetworkItems</key>
<array>
<dict>
<key>SKAdNetworkIdentifier</key>
<string>zq492l623r.skadnetwork</string>
</dict>
</array>