britzl / extension-admob

Admob extension for Defold.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Admob extension for Defold

Documentation

Full documentation can be found here: http://docs.spiralcodestudio.com/extension/admob

Functions

Events

Project Settings

To use this extension, open game.project and add two entries into the dependencies property:

  • https://github.com/Lerg/extension-admob/archive/master.zip
  • https://github.com/defold/android-base-extensions/releases/download/1.0.0/gps-base-16.0.1.zip
  • https://github.com/defold/android-base-extensions/releases/download/1.0.0/gps-ads-17.2.1.zip
  • https://github.com/defold/android-base-extensions/releases/download/1.0.0/support-v4-27.0.2.zip
  • https://github.com/defold/android-base-extensions/releases/download/1.0.0/gps-measurement-16.4.0.zip

Then select Project -> Fetch Libraries to download the extension in your project.

You need to set the AdMob App Id for your iOS and/or Android app in game.project. To do so open your game.project and add these lines:

[admob]
ios_app_id = ca-app-pub-***~***
android_app_id = ca-app-pub-***~***

Replace ca-app-pub-***~*** with your app ids. It can now be viewed or changed in the normal view of the game.project file.

Test Ads

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.

Demo

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.

Usage

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().

Impressions Share

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.

About

Admob extension for Defold.

License:MIT License


Languages

Language:Objective-C 78.1%Language:C 15.3%Language:C++ 5.4%Language:Lua 1.2%