Unity: Implementing Amazon ads
I ended up ripping Prime31’s Android AdMob support out of Transmutation, writing my own plugin, and then adding Amazon to support to it.
Because Prime31 offered no help or useful information for the AdMob-crashing-on-the-Fire-HD problem, the only way I could figure out what was causing it was to write my own replacement for it.
Two days later, I can confirm that the Prime31 is breaking just like mine is. Prime31 support randomly pointed the finger at AdMob, but I’ve found reports of Amazon ads locking up on Android devices the same way that AdMob ads do on Amazon devices. I’d guess that it’s probably something that Amazon has done.
Regardless, I still consider Prime31’s plugin as $95 wasted because I had to spend two days learning and writing an Android plugin just to confirm that Prime31’s AdMob doesn’t work on Amazon devices.
Amazon’s ad implementation is pretty similar to AdMob, with the exception that Amazon ads don’t aut0-refresh. It’s up to the developer to implement some sort of timer that will destroy and re-create the ad view every 30 seconds or so. Rather than build a refresh function into the plugin, I used a coroutine from within Unity that fires every time an ad appears, getting it ready for the next one.
One feature of Amazon ads that gave me a lot of trouble were the expandable banners, which the Fire HD test ad demonstrates. Unlike AdMob, Amazon’s ad view passes clicks through to the app, which meant that when a user was looking at a full screen ad, clicking on it would also trigger any of the app’s buttons that happened to be located beneath it.
There’s probably some sort of official Android technique for flagging a layout/view so that it won’t pass clicks to Unity, but I’m not an Android java developer, so I have no idea. I ended up hacking around it by implementing the onAdExpanded and onAdCollapsed events to put a full-screen box collider on top of the GUI, which soaks up clicks that fall through.
Update: Since writing this I went through the process of submitting my implementation to the Unity Asset Store. Unfortunately, it was rejected due to internal business reasons at Unity HQ. Because of this, I released it on this website. Download it here.