Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

157
Views
Is this the right way to load applovin interstitial ad in ionic

So in my ionic project I`m trying to load interstitial ad, the same is not showing in my emulator device, I picked the code from applovin documentation cordova, I also integrated the what they asked me in gradle files, and of course I did the plugin. I was wondering if Ionic doesn't accept this way or I should convert it to typescript. I putted this code in home.page.ts calling the interstitial ad when a certain button is clicked.

declare var window: any;
declare var cordova: any;
declare var bannerAdUnitId: any;
var AppLovinMAX = cordova.require('cordova-plugin-applovin-max.AppLovinMAX');


AppLovinMAX.initialize("RAfucl4TfsPn8kt_iKFCoFsaI59861MbWMxU6W_6JIV6eHL42gFPgE6xps14lF00MfnHNCOenKVfPKV8vf7IqN", function (configuration) {
    // SDK is initialized, start loading ads
});

var INTER_AD_UNIT_ID;
if (window.cordova.platformId.toUpperCase() === 'IOS') {
    INTER_AD_UNIT_ID = 'YOUR_IOS_INTER_AD_UNIT_ID';
} else {
    // Assume Android
    INTER_AD_UNIT_ID = '';
}

var retryAttempt = 0;

function initializeInterstitialAds()
{
    window.addEventListener('OnInterstitialLoadedEvent', function (adInfo) {
        // Interstitial ad is ready to be shown. AppLovinMAX.isInterstitialReady(INTER_AD_UNIT_ID) will now return 'true'
        
        // Reset retry attempt
        retryAttempt = 0;
    });

    window.addEventListener('OnInterstitialLoadFailedEvent', function (adInfo) {
        // Interstitial ad failed to load 
        // We recommend retrying with exponentially higher delays up to a maximum delay (in this case 64 seconds)
    
        retryAttempt++; 
        var retryDelay = Math.pow(2, Math.min(6, retryAttempt));

        console.log('Interstitial ad failed to load - retrying in ' + retryDelay + 's');
          
        setTimeout(function() {
            loadInterstitial();
        }, retryDelay * 1000);
    });

    window.addEventListener('OnInterstitialClickedEvent', function (adInfo) {});
    window.addEventListener('OnInterstitialDisplayedEvent', function (adInfo) {});
    window.addEventListener('OnInterstitialAdFailedToDisplayEvent', function (adInfo) {
        // Interstitial ad failed to display. We recommend loading the next ad
        loadInterstitial();
    });
    window.addEventListener('OnInterstitialHiddenEvent', function (adInfo) {
        loadInterstitial();
    });

    // Load the first interstitial
    loadInterstitial();
}

function loadInterstitial()
{
    AppLovinMAX.loadInterstitial(INTER_AD_UNIT_ID);
}

if (AppLovinMAX.isInterstitialReady(INTER_AD_UNIT_ID))
{
    AppLovinMAX.showInterstitial(INTER_AD_UNIT_ID);
}
about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!