How to use Admob Phonegap plugin with iOS

2019-09-02 08:18发布

问题:

I'm using this Admob plugin for Phonegap running on iOS like this:

window.plugins.AdMob.createBanner({"siteId":"my-site-id"});
window.plugins.AdMob.loadBanner();
// move banner to make it appear
window.plugins.AdMob.moveBanner({"positionX":0,"positionY":410});

And it's actually working. The problem is that this is causing my app to consume a lot memory, and the app to crush when on a device according to the Apple crash report I got from iTunesConnect.

Can you help me in understanding how to use this plugin?

Thanks!

回答1:

Are you using the deletBanner: method anywhere? I think there may be a memory leak there possibly. The plugin looks like it removes the adBanner property from its superview and nil's it out, but I think it may need to also:

  • Set the delegate for adBanner to nil
  • Release the adBanner (you can double-check this by seeing what the retain count of the adBanner is). I think UIViewController's dealloc automatically calls removeFromSuperView: but deleteBanner: probably wouldn't do that?