react-native-admob / admob

Admob for React Native with powerful hooks and components

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Event adDismissed not getting fired, after closing ad

tmjordan opened this issue · comments

Description

Expected behavior: Event adDismissed should be triggered when an ad gets closed or dismissed

Actual behavior & steps to reproduce

Nothing happen. Not getting notified after closing an ad

Snack or minimal code example

    this.advert = InterstitialAd.createAd(admob_interstitial_id);
    this.advert.load();
    this.advert.addEventListener('adLoaded', () => {
        this.adLoaded = true;
        console.warn('Advert ready to show.');
    });
    this.advert.addEventListener('adDismissed', () => {
        Cache.setItem('viewedProfiles', 0);
        // this.closeChat();
    });
    this.advert.addEventListener('adFailedToLoad', error => {
        this.adFailedToLoad = true;
        console.warn('Advert failed to load.', error);
    });

Package versions

  • React Native: 0.66.1
  • React Native AdMob: 1.1.2
  • Google Mobile Ads SDK(if specified):
  • Xcode: 13
  • Java & Gradle: Gradle 6.9

Affected platforms

  • [x ] Android
  • [x ] iOS

This is maybe because you loaded ad twice. Ad is loaded automatically unless you specified its option.loadOnMounted to false.

Try remove the line this.advert.load() or create ad with above option for example:

this.advert = InterstitialAd.createAd(admob_interstitial_id, {
  loadOnMounted: false
});

Feedback me if it does not work.

Oh, I found you are using previous version. Also you should try version 1.2.1

@wjaykim Thank you for your support. Ok i will try the last version and i will let you know

@wjaykim thank you, the last version fixed the problem