admob.* — Admob
The Admob extension lets you display banner, interstitial and rewarded ads.
To use this extension, open
game.projectand add an entry into the
https://github.com/Lerg/extension-admob/archive/master.zip. Multiple items can be separated by a space character.
Project -> Fetch Librariesto download the extension in your project.
Android Resources bug
Oops, turns out there is a bug in Defold preventing the extension from building for Android when used as a remote dependency. Resources don’t get bundled.
As a workaround please download the extension from github https://github.com/Lerg/extension-admob/archive/master.zip and copy the admob directory into your project. And the extension has to be removed from the
dependencieslist if added already in game.project.
AndroidManifest.xml has to be modified for full Android support. You can use the provided manifest file. Download it and put it into your project directory.
game.project and scroll down to
android -> Manifest option, select or paste path for the manifest file from the extension:
Another file -
game.appmanifest has to be added to the
game.project file to tell Defold not to bundle it’s own Google Play Services and Support libraries. This extension provides updated versions of these libraries.
Again, download it and put it into your project directory. Scroll down to
native_extension -> App Manifest and select
ALWAYS use test ads during the development. Only switch to the real ads for submitting to the stores. To enable test ads use
test = true option in the admob.init() call.
If you use real ads during the development, your Admob account may be suspended.
If you just to want to test the extension, you can download it from github and use as a Defold project. It will function as a demo. You don’t need an Admob account for the demo.
Use admob.init() to initialize it when your app starts. A good place for that would be the
init() function of some root game object. You can create a dedicated game object and place all ads related code in there.
Once the init process if finished (you can listen for the
'init' phase/type in the admob event or you can just wait), you can start loading ads. It’s good to preload ads before you actually need to display it. Use admob.load() to load and admob.show() to show the ads.
When an ad has been closed (phase equals
'closed') you can preload next ad.
Banners are displayed automatically when loaded, no need to call admob.show() for them, however to remove a banner, you would need to use admob.hide_banner().
The extension will serve 1% of all impressions to it’s owner benefit. By using this extension you agree with that. Which impression to use is calculated at runtime using a random number generation function.