sbugert / react-native-admob

A react-native component for Google AdMob banners
BSD 2-Clause "Simplified" License
1.13k stars 532 forks source link

Ad not showing in iOS #540

Open rahulje9 opened 3 years ago

rahulje9 commented 3 years ago

Hi,

I have followed all the steps and set up everything but no matter what ad is not showing on the physical iOS device. I wasn't getting the ad in the simulator too, but for the past few days, I'm seeing ads in the simulator. everything is working fine on the android side. I'm calling a function to show an ad and the code for it is as follows.

  componentDidMount() {
    AdMobRewarded.setAdUnitID(this.rewardID);
    AdMobInterstitial.setTestDevices([AdMobInterstitial.simulatorId]);

    AdMobRewarded.addEventListener('rewarded', (reward) => {

    /*this function will reward the user for seeing ads*/

      this.addTickets('ads');

    });
    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.requestAd().catch((error) => {});
    });
    AdMobRewarded.addEventListener('adLeftApplication', () =>
      console.log('AdMobRewarded => adLeftApplication'),
    );
    AdMobRewarded.requestAd().catch((error) => {});
}
    AdMobRewarded.showAd().catch((error) => {
      Toast.show('Ad is not ready, Please try after sometime.');
    });

Package versions

    "react": "16.9.0",
    "react-native": "0.61.5",
    "react-native-admob": "^2.0.0-beta.6",

do I need to start a campaign in Google Ad-Mob for ads to show on the iOS device? it would be very grateful if someone helps me with this

zubinraja commented 3 years ago

Facing same issue. any solution on this

MutableLoss commented 3 years ago

Make sure your device is setup as a test device on your Admob profile (app > settings > test devices). The IDFA you need for this you can get using a 3rd party application (e.g. "My Device Id").

rahulje9 commented 3 years ago

Make sure your device is setup as a test device on your Admob profile (app > settings > test devices). The IDFA you need for this you can get using a 3rd party application (e.g. "My Device Id").

Thanks for this, I have one more doubt. So how will this work with the apps listed on the appstore? My app is already there in the appstore.

Edit: now I'm getting [Error: Request Error: Internal error.]

zubinraja commented 3 years ago

@MutableLoss Thank you. will try to register real device as test device in Admob. But I am facing the issue in emulator! Which is default test device. Also, the banner and native ads works perfectly fine as testmode in emulator. Only the Interstitial ads has the issue.

rahulje9 commented 3 years ago

@zubinraja try this after setting ad unit id AdMobInterstitial.setTestDevices([AdMobInterstitial.simulatorId]); for me, all the issues were in the simulators and iOS devices. is your app in the play store?

zubinraja commented 3 years ago

Thanks @rahulje9 here is my code AdMobInterstitial.setAdUnitID('xxxxxxxx'); AdMobInterstitial.setTestDevices([AdMobInterstitial.simulatorId]); AdMobInterstitial.requestAd().then(() =>{ AdMobInterstitial.showAd();
})

rahulje9 commented 3 years ago

@zubinraja I'm having a similar setup but using AdMobRewarded as I need that one. I have added the code in componentDidMount as I have added a listener for the reward events. Did you add the necessary codes in the android manifest file?

zubinraja commented 3 years ago

@rahulje9 Weill in android everything is working cool. in ios facing issue with only interstitial. rest like banner, reward, native ads working cool

rahulje9 commented 3 years ago

@zubinraja Okay, even ads were not showing in the simulator for a really long time, and then it started showing, and then stopped then again started getting ads, no Idea why it is like that. while looking in every forum I was seeing similar issues.

MutableLoss commented 3 years ago

What I mentioned was specific to ads not showing on an iOS device in testing (replying to the OP). This was a common issue for me when testing on a device, as google determines the ID of each device via the the IDFA before showing an ad.

For what it's worth, I also had issues with ads in the iOS simulator early on, but the cause was specific to the validity of my new Admob account. When I got everything sorted on my account, I never had another issue in the simulator. 👍

Also, in terms of Published apps not showing ads, did you disable the test keys in the ad components?

EDIT: This Admob support page was very helpful in finding the causes for my ad issues: https://support.google.com/admob/answer/9469204?hl=en

zubinraja commented 3 years ago

Tried reward video ads, with the same logs you have kept. And getting below result. All events happens without actual ad is displayed!

[Wed Dec 16 2020 02:09:57.242] LOG AdMobRewarded => adLoaded [Wed Dec 16 2020 02:10:01.904] LOG AdMobRewarded => adOpened [Wed Dec 16 2020 02:10:01.904] LOG AdMobRewarded => adClosed [Wed Dec 16 2020 02:10:03.442] LOG AdMobRewarded => adLoaded

zubinraja commented 3 years ago

New finding to the original issue. observe the code componentDidMount() { AdMobRewarded.setAdUnitID('<unitid>'); AdMobRewarded.setTestDevices([AdMobRewarded.simulatorId]); AdMobRewarded.requestAd(); }

`showVideoAd(){

AdMobRewarded.showAd();

  AdMobRewarded.addEventListener('adLoaded', () =>
      {console.log('AdMobRewarded => adLoaded')
      if(this.state.displayVideoAd === true)
          return;
        console.log("show ad");
        AdMobRewarded.showAd();
      }
    );
    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.requestAd().catch((error) => {});
    });
    AdMobRewarded.addEventListener('adLeftApplication', () =>
      console.log('AdMobRewarded => adLeftApplication'),
    );

AdMobRewarded.addEventListener("rewarded",() =>{

});  

AdMobRewarded.addEventListener("videoStarted",() =>{
    this.setState({displayVideoAd: true});
    AdMobRewarded.removeAllListeners();
  });

  AdMobRewarded.addEventListener("adFailedToLoad",() =>{

  });

}`

called showVideoAd function on submit click, but it didn't showed the ad. after few seconds, when I closed the modal screen the ad appeared and worked well.

fernandopascoalbr commented 3 years ago

some solution?

MutableLoss commented 3 years ago

I have to be honest, once I got it to show interstitial/reward ads reliably, it was still an uphill battle to consistently show ads afterwards; there are just too many ways to cause ad load crashes. Since this shouldn't be an issue, and it hasn't be addressed by the maintainer, makes me think the module has since been abandoned.

some solution?

I ended up switching to react-native-firebase/admob . Not only did I stop having ad load issues (easy transition btw), but I also gained access to other options this module doesn't offer (content ratings, consents, personalized ads, etc).