Delphi - monetize Android/iOS applications step-by-step

Delphi is a great friend when you have to develop an Android/iOS app easily and quickly; once you have created an application you can distribute it using the Play Store (Android) or the Play Store (iOS). A very efficient tactic to gain money using your application is placing it in the stores at a low price or, better, place your app for free and put advertisement on it. Of course we can do it easily with Delphi. Let's do it step by step!



  1. AdMob (by Google) is a mobile advertising company that works for Android and iOS apps; we are going to use this. First of all visit the official website and click Sign up on the top. You need to have a valid gmail account. AdMob requires:
    • AdWords: if you already have an account you're fine, otherwise a new one will be created for you.
    • AdSense: this is used to show advertisements (ads) on websites (Google ad banners come from here) and on mobile devices. You need an active account.

    If you don't already have an AdSense account don't worry, there is a trick! In order to obtain an active AdSense account we need to sign up and put the URL of a website or blog that we own and wait that google approves it. What if our account doesn't get approved? Don't worry! AdMob requires an active AdSense account, so once you've signed up and put the URL of a website, you'll see in the home page that google is verifying your website. That is enough, now you can proceed and sign up to AdMob! :) You won't be able to use AdSense banners or get money from it until it's approved, but you will be able to get money from AdMob!

  2. Log in in AdMob using your account and it will guide you with the "first installation" process. You will be asked to search your application (App Store or Play Store) and then you'll have to generate an ad unit. Once you've finished go in the home page, click Apps, selecy your app and copy this ID:



    This is in italian but of course you'll see something like this in a different language! :) The Ad Unit Id is the most important code you have to copy/paste in the Delphi app. My application is called "Calcolo Combinatorio" and it the ad banner is linked to my app with that ID.

  3. Now open Delphi! You have to select Android as Target Platform, drop a TBannerAd component and align it to Top or Bottom. Now we have to consider something REALLY important:

    • Do NOT click on your own ads in your app or you'll get banned from AdMob!
    • Once you've created the ad unit it needs some "activation time"; this means that you don't have to panic if you don't see your ads immediatly. Just wait a few time! The first time for example I had to wait for almost 20/30 minutes.
    • Do NOT give to the TBannerAd component a fixed width or height. If the component is too small (too small width for example), it won't appear and you'll get an error. Always set it to Top or Bottom (or Client or whatever) and set the AdSize as you prefer (I always do small). Never hard-code the size but let it be always aligned to something so you won't have problems


  4. We are ready! We have our great Delphi app and the Ad Unit id. Let's go in the Structure view of the IDE, click on the Form, add an OnShow event and put the following code:

     if (BannerAd.AdUnitID = '') then
       BannerAd.AdUnitID := 'ca-app-pub-7xxxxxxxxxxxxxxx/9xxxxxxxxx';
    
     BannerAd.LoadAd; 
    


    Now we have to go on Project > Options > Entitlement List and check the AdMob Service so that it becomes True. To be sure that our ad works, set the TestMode of the BannerAd1 component to True. Now when you run yout app (be sure that you have an active internet connection) you should see the AdMob test banner. For example, if you set the size to Small should look like this:


If you can see the test banner, congratulations! You have just added an ad banner to your app :) Now to show the real ad banners that give you money, uncheck the TestMode property so that it's set to False. Click Project > Build and the Project > Deploy. You will be able to see the ads on your app! Here's an example with mine :)



I'll say it again: do NOT click of your own ads or you'll get banned from admob! If you click on them once (by mistake) don't worry but don't do it 2/3 times in a row or you'll risk.

Should I put ads in my app?

It depends! Consider the day (24 hours). If you have 20 active users that visit your app and click on the banner every time you'll gain X euro/dollars. If you have 100 not active users that use your app sometime and don't always (or never) click on the banner you'll get Y euro/dollars. In this case the value of X will be bigger than Y by a lot, so you are going to gain more money from the first scenario (only 20 users, but active).

What I wanted to tell you above is that you don't have to care about the number of downloads of your app. Google AdSense cares about the active users that you have (= who views the ads or, better, who clicks on it)! If an user views your ad banner you are getting basically nothing but if he clicks on the banner you'll get some money.

Basically: you don't gain money when the user views your ads (in some cases you do, but it's a veeery tiny amount) but you get money when they click on them. If you have an app that is used daily by a lot of users, that you have a big chance of clicks and then go for AdMob!


Good luck and happy Delphi coding!

Comments

Popular posts from this blog

Delphi - Android full screen splash

Delphi - TLanguage localizaton tool