I have just released Admob extension for OpenFL and would like to share it with you.
You can install it with haxelib:
haxelib install admob-openfl
Before I was using the following extension for Admob:
But it requires lots of actions, like replacing AndroidManifest.xml and GameActivity.java, what I didn’t like.
Mine is much simpler to use, and doesn’t require any special actions.
On the other hand, it doesn’t support iOS. So, if someone wants to add iOS support to the extension, please let me know!
Nice work,
This is my first time implementing ads in mobile app and your extension is very beginner-friendly compared to the others.
I have followed the instruction on github and it worked flawlessly when displaying banner ads in my project.
but when I’m trying to display interstitial ads, somehow it’s stuck after calling admob.cacheInterstitial(). and the event AdmobEvent.INTERSTITIAL_CACHE_OK is never connect to the listener function.
Make sure you are using latest version 0.0.2 from haxelib and also you have initialized the extension and received INIT_OK event before calling cacheInterstitial().
public function new () {
super ();
admob = new Admob();
admob.addEventListener(AdmobEvent.INIT_OK, onAdmobInit);
admob.addEventListener(AdmobEvent.INTERSTITIAL_CACHE_OK, onAdmobCache);
admob.init();
}
private function onAdmobInit(e:AdmobEvent):Void{
admob.cacheInterstitial(ADMOB_UNIT_ID);
}
private function onAdmobCache(e:AdmobEvent):Void {
admob.showInterstitial();
}
Silly me, I just found out that there is nothing wrong with the code or the extension, it’s just the admob unit id. I used the banner ads id to display interstitial ads, it seems that I must create another ad unit id to display interstitial. It works like a charm now.