ratson / cordova-plugin-admob-free

New development has been moved to "admob-plus-cordova", https://github.com/admob-plus/admob-plus/tree/master/packages/cordova
https://github.com/admob-plus/admob-plus
MIT License
495 stars 211 forks source link

interstitialAd is null, call #60

Open Flavioamorim opened 7 years ago

Flavioamorim commented 7 years ago

hello,

I'm trying to use the interstitial banner, but I always return the same error: interstitialAd is null, call

  admobid = {
     banner: 'ca-app-pub-5322935628707109/xxxxx',
     interstitial: 'ca-app-pub-5322935628707109/xxx',
   }

  admob.banner.config({
    id: admobid.banner,
    isTesting: true,
    autoShow: true,
  })
  admob.banner.prepare()

  admob.interstitial.config({
    id: admobid.interstitial,
    isTesting: true,
    autoShow: false,
  })
admob.interstitial.prepare()
admob.interstitial.show()

I am using ionic 1 and am calling the above code in method: $ionicPlatform.ready(function() {});

help me please

ratson commented 7 years ago

Did you tried the example code?

lfveigas commented 7 years ago

Hi,

I'm having the same issue on Ionic 1 also, although the pub is showing up, both banner and interstitial.

The errors are: Uncaught (in promise) adView is null, call createBannerView first. Uncaught (in promise) interstitialAd is null, call createInterstitialView first.

Is this an issue with Ionic 1 only?

Thanks and Regards

rafaellop commented 6 years ago

Prepare ads first. This happens if banner or interstitial is not prepared. Then in LOAD events show the ad.

@ratson It's not ionic 1 related. I use the plugin with ionic 1 and it works perfectly well.

MichaelHuy commented 6 years ago

also happen with ionic2/3 Android version

rodrigograca31 commented 5 years ago

@lveigas have you solved the issue for Ionic 1?

These seem to be the "problematic" lines: https://github.com/ratson/cordova-plugin-admob-free/blob/b0d6945d7ebf29bfa193308458f5d69f00d880f6/src/android/banner/BannerExecutor.java#L173 and: https://github.com/ratson/cordova-plugin-admob-free/blob/b0d6945d7ebf29bfa193308458f5d69f00d880f6/src/android/interstitial/InterstitialExecutor.java#L127

Both return the reported errors, and note that there's a very similar phrase but without the . (dot) in the end....

lfveigas commented 5 years ago

Hi @rodrigograca31,

Yes, I did solve it, but I don't remember exactly how since it was a long time ago, but I believe it was by preparing the ads first, invoking createBannerView and createInterstitialView methods before showing the ads.

Hope this helps.

Regards, Luís Veigas

rodrigograca31 commented 5 years ago

I did some testing and seems "the problem" for banners at least is because we are using autoShow: true and then admob.banner.show() but the ad was already shown so there's no adview