Firebase Rescues Game Players from Too Many Ads

Playing Plasma

Nobody likes interstitial ads between their free games.

This is what I’ve come to find out as I’ve learned how to develop for Android. Nobody likes them. In fact, I’d say that most negative reviews I’ve seen are rooted in interstitial irritation. Too many, they say, it’s just too many.

However, I’ve seen the same folks say that they understand the developers want to make some cash for their hard-earned typing of 0s and 1s. But does it have to be between EVERY game?

Let’s not piss everyone off on our first game, I said to Eric a couple of weeks ago. Let’s find a way to not irritate the hell out of our players.

Enter Firebase remote config – a nifty tool that Google gave us Android content producers. Remote config allows you to make changes to configuration variables without having to build/release. I imagine Firebase Functions also can help with this, but right now, we’re heavy into remote config. It’s simple and accessible.

Firebase also allows you wrap those config variables in conditions — and those conditions can be set up to tie into analytics. RAD, as the kids used to say.

So back to the interstitial issue. We found our way to interstitial Zen via Firebase. To prevent ads from being shown too often (or not enough), we set a minimum threshold — our default is somewhere around 3 minutes. This means our players can keep forwarding through games and will only be presented with an interstitial ad if it’s been 3 minutes since the last ad was presented —- not simply inbetween every game.

But even more rad to us is being able to add a condition — a user property or a percentile. We can use this information to set the interstitial ad threshold and make adjustments to optimize the experience for our player while we still earn some ad revenue. It’s really a simple bit of code that’s at the heart of the matter:

private boolean okInterstitch() {
    long msBetweenAds = mFirebaseRemoteConfig.getLong("msBetweenAds");
    long rightNow = System.currentTimeMillis();
    return (rightNow - adLastShown) > msBetweenAds;
}

See? We get the remote config variable, msBetweenAds, and check it against the last time an ad was run. If it’s OK to run the interstitial, we send a “true” return value indicating to play the ad:

private void updateInterstitch() { 
    if (okInterstitch()) { 
     if (mInterstitialAd.isLoaded()) { 
         mInterstitialAd.show(); 
         adLastShown = System.currentTimeMillis(); 
     } else { 
        setupInterStitchAd(); 
     } 
    } 
}

There’s also a check to see that the ad has loaded and if it hasn’t for some reason, we go over and run the ad setup method.

We plan on using this more and more as Plasma launches and will fill you in on how it goes! What are you using Firebase for? Bet you are using it for something cool. I’d love to know. 🙂

About Friday

Developer, gardener, animal lover. Wife of a puzzlemonster. My coding resume shows my age: Wordperfect reveal codes => HTML => ASP Classic => SQL => JavaScript => jQuery => PHP => Wordpress under-the-hood => Java => Android dev.

View all posts by Friday →

Leave a Reply