Monetizing Your Apps: AdMob

      1 Comment on Monetizing Your Apps: AdMob

If you have a free app and you're thinking of ways you can monetise that app one of the most common ways is to put some ads in the app.If you have a free app and you’re thinking of ways you can monetize that app one of the most common ways is to put some ads in the app. In this article we’ll quickly go over how to set up AdMob and implement the three ad types they offer… Let’s make some money πŸ™‚

Setting up AdMob

If you’re using firebase, you can sign up for AdMob from the dashboard:

Signing up is pretty straightforward. Next you’ll need to add your app. If you already published your app on the App Store this step will be quite simple, simply search for your app:

If you haven’t published your app yet, you can simply enter the name of it, and select the platform. After this step you’ll get your publisher ID, which you’ll need to initialize the AdMob SDK. I would suggest you link your AdMob account with your Firebase as well.

You might have skipped the last step where AdMob asked you to create an ad unit. No worries. Select your app from the menu on the left and click on ‘Ad units’:

You’ll see a big blue ‘Add Ad Unit’ button, when you select it, you’ll have to choose between the three available types. Banner, Interstitial and Rewarded Video:

In this example I’ll be talking about the rewarded video, because it’s a bit different from the other two. I’ll quickly touch on how to implement them in code. But we’ll focus on the rewarded video.

Rewarded Video

You’ve probably seen all three types of ads in other apps. A banner is a simple banner that’s displayed somewhere on the view. Interstitial is a full screen modal that displays a static image. Rewarded video is a bit different. It’s a video that’s displayed modally, just like an interstitial. Your users can dismiss the video at any time. But, if they watch it for a certain period of time, they get a reward. A reward is just a simple key and a value. Depending on your app, you will decide what it means. For example, if you have a game a reward might be 5 coins.

So go ahead and select the ‘Rewarded’ ad type from the screen above. You can set the key and the value of it on the next screen:

Here our reward key is ‘Reward’ and the value is 2. In this example, we’ll reward our users by increasing the number of slots they can use to save favourites by 2. Once you create the ad unit, you’ll get the ad unit id. You’ll need this later when implementing it in the code.

The Code

Adding the SDK to your project is quite simple if you’re using cocoapods (which I would recommend), simply update your podfile:

And run ‘pod update’ from the terminal. There you have it. We still have to initialize the SDK, so in your AppDelegate import the SDK:

initialize the SDK somewhere in your ‘didFinishLaunching’ method in the AppDelegate:

Obviously, put your app id that you got when you created the app on AdMob.

Displaying the Ad

You’ll probably have a button on your view controller that the user will tap on if she wants to see the ad and receive the reward. Don’t display these ads programatically when you want, your users have to consent to seeing the ad, otherwise you might get banned from AdMob.

What you should do is preload the ad, and you can easily do this in the ‘viewWillAppear’:

Don’t forget to set yourself as a delegate, otherwise you won’t know if the user should receive the reward. This will preload the ad, so when your user taps on the button it will display without delay. Your button action might look something like this:

And now when your user watches the ad you will get a delegate callback:

Now, this is the method where you should actually reward your user. In our fictive example, we said we’ll increase the number of slots a user can use for favourites by two. A reward is something that will be unique for your app, so there’s little benefit of me boring you with that code πŸ™‚

Banners and Interstitials

Banners and interstitials are your classic ads that you’ve seen all over the place. They are pretty simple to implement. A banner is just a view that you add to your view hierarchy (be it from code or from interface builder). Let’s say you have your bannerView:

You might want to set the delegate here because you could animate the banner into the screen when the ad is loaded.

Interstitial is basically a full screen static ad, and is displayed modally, much like the rewarded video. It’s actually the simplest to use out of the three. You initialize it in ‘viewDidLoad’:

And then somewhere in the code, programatically or as a result of a user action, you display it:

That’s pretty much it. Now you know all you need to know to implement ads into your apps.

Conclusion

AdMob is a simple and fast way to start making some money with your apps. Apart from displaying banners and interstitials you can also show rewarded videos which pay a lot more. Of course, you’ll have to provide your users with something in return. In this article we went through a quick example of setting your AdMob account and implementing a rewarded video ad. I hope you learned something from it, and I hope you’ll start making some money out of your awesome ideas.

Have a nice day πŸ™‚

Dejan.

More resources

One thought on “Monetizing Your Apps: AdMob

  1. Farwa Rizvi

    Excellent blog!! this is really great article about monetization of apps and games . you are saying right about admob but i would recommend consoliads which is best mobile ad network platform for monetization

    Reply

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.