DefAds - Showing ads on mobile using a webview


I decided to put together a proper library project for showing ads using the webview component released in Defold 1.2.84. It should be fairly straight forward to integrate this in your own mobile project and show ads with just a few simple steps. You can check out the project and read more about how to integrate it here:

There’s also an example project showing the integration here:

Facebook and Ads
Calling JS function from Lua code (DEF-1782)
Where are the ads support?
Defold Editor 2.0

Exellent share.
You’re really awesome and make great work and share for all the community.


I agree.
@britzl is a nordic Defold god.


Ha! I should print business cards with that title!


I have updated DefAds to version 0.4. The new version brings with it a change in the setup where DefAds will no longer set itself up as IAC listener since that might interfere with if the app is already using the IAC module for something else. If you are using DefAds then please follow the updated steps in the readme (step #5 is new, the rest is unchanged).


DefAds has been updated to version 0.5. This release includes support for Giftgaming ads. I have also done additional testing on iOS to fix a couple of issues.


Thanks @britzl!

Everyone, please head over to our thread for more information about giftgaming!


@britzl, I’m terribly sorry to bother you, but, can you share a working example of using adsense in defAds


When i’m trying to use Adsense, it shows only a white screen with a “X” button and a string “BELOW” in left top corner.
What i’m doing wrong?


I remember having some issues with Adsense, but I can’t recall the details. If you are testing on Android then make sure to build a non-release build. Then take a look at the log:

adb logcat -s chromium

This should show if the webview runs into any Javascript errors or anything like that or if the Adsense SDK gives you any hints.


c:\Program Files (x86)\Android\android-sdk\platform-tools>adb logcat -s chromium --------- beginning of /dev/log/system --------- beginning of /dev/log/main D/chromium( 4715): Unknown chromium error: -6


@britzl Today I tried to use your library, unfortunately I can’t integrate it.
Too many issues:

  • add_error message all time
  • when I tap to AD I can’t return to the app
  • some networks doesn’t work or work very strange
  • video ads doesn’t work

Look forward to native ad sdk.
Anyway thanks for your work.


Really? That’s a shame. I’ll see what I can do to improve it.

I can reveal that Mathias has started working on an AdMob extension based on out new extension system. Things seem to be progressing well and I hope that we can share a teaser here on the forum soon. I can’t wait until we can get the extension system into the hands of you guys and see what you can make with it! I’m really impressed by what I’ve seen of the system so far!


@britzl As I understand you have no checking for sponsor availability for gift gaming?


Ah, no, that is correct. I don’t. That’s an additional API call before deciding if the ad should be shown or not, right?


yes, it is api for checking availability of sponsor (ad)


I’ve added support to do a prefetch and get a callback when there is an ad available. I also added the GiftGaming ad tracking parameters to increase CPM. To prefetch an ad do the following:"url_to_giftgaming_go", "prefetch", { apikey = "12345abcde", test = false })

This will post either a prefetch_ok or prefetch_failed message back to the sender. If prefetch_ok is received there’s a 30 second window to post a show message to show the prefetched ad.


I’m new to mobile advertising. What kind of ads do these networks provide? Are they safe for an app targeted to children?
Few years ago Leadbolt gained a bad reputation for very intrusive ads:

I’d like to hear someone with first hand experience.


I’m not sure if anyone is actually using any of the ad networks included in DefAds. Bear in mind that DefAds uses the webview API and can thus only show fullscreen ads. We recently released support for native extensions and this has opened up the box so to speak when it comes to including many more Ad SDKs and also supporting the full range of features from those networks. We (the Defold team) will release an AdMob integration sample soon and there is an ongoing implementation of Appodeal ads, made by the Appodeal guys themselves. Read more about this here and give it a try yourself!


I can’t try the Appodeal extension because it’s only for iOS. Anyway I’m a bit confused about lack of Defold proper ads support, being Defold a King product I thought it was targeted to making commercial games, but until now it seems ads support was not a priority. I hope this will change really soon.