AppLovin / AppLovin-MAX-React-Native

MIT License
55 stars 29 forks source link

Interstitial ads not coming #364

Open Avinashsinh007 opened 1 month ago

Avinashsinh007 commented 1 month ago

MAX Module Version

7.1.0

React Native Version

0.74.5

Device/Platform Info

pixel 8 pro

Current Behavior

the interstitial ad not coming as the app starts, it takes too much time to load the first ad even for the test advertise

Expected Behavior

it should shown as the app load

How to Reproduce

const retryAttempt = useRef(0); useEffect(() => { AppLovinMAX.initialize(SDK_KEY) .then(conf => { console.log('conf=====>>>>>>>>>>', conf); AppLovinMAX.initialize(SDK_KEY) .then(async conf => { await loadInterstitial(); }) .catch(error => { console.log('error', error); }); }) .catch(error => { // Failed to initialize SDK console.log('error', error); }); InterstitialAd.addAdLoadedEventListener(adInfo => { console.log('Interstitial ad loaded from ' + adInfo.networkName); // Reset retry attempt retryAttempt.current = 0; }); InterstitialAd.addAdLoadFailedEventListener(errorInfo => { if (retryAttempt.current > MAX_EXPONENTIAL_RETRY_COUNT) { console.log( 'Interstitial ad failed to load with code ' + errorInfo.code, ); return; } retryAttempt.current += 1;

  const retryDelay = Math.pow(
    2,
    Math.min(MAX_EXPONENTIAL_RETRY_COUNT, retryAttempt.current),
  );

  setTimeout(() => {
    console.log('Interstitial ad retrying to load...');
    InterstitialAd.loadAd(INTERSTITIAL_AD_UNIT_ID);
  }, retryDelay * 1000);
});

}, []); const loadInterstitial = async () => { const isInterstitialReady = await InterstitialAd.isAdReady( INTERSTITIAL_AD_UNIT_ID, ); if (isInterstitialReady) { InterstitialAd.showAd(INTERSTITIAL_AD_UNIT_ID); } else { console.log('Loading interstitial ad...'); InterstitialAd.loadAd(INTERSTITIAL_AD_UNIT_ID); } };

Additional Info

No response

alhiwatan commented 1 month ago

@Avinashsinh007, could you take a look at our example and try running it to see how it works? It seems that showAd() may not be called in your program, and initialize() should not be called twice.