• Dear Cerberus X User!

    As we prepare to transition the forum ownership from Mike to Phil (TripleHead GmbH), we need your explicit consent to transfer your user data in accordance with our amended Terms and Rules in order to be compliant with data protection laws.

    Important: If you accept the amended Terms and Rules, you agree to the transfer of your user data to the future forum owner!

    Please read the new Terms and Rules below, check the box to agree, and click "Accept" to continue enjoying your Cerberus X Forum experience. The deadline for consent is April 5, 2024.

    Do not accept the amended Terms and Rules if you do not wish your personal data to be transferred to the future forum owner!

    Accepting ensures:

    - Continued access to your account with a short break for the actual transfer.

    - Retention of your data under the same terms.

    Without consent:

    - You don't have further access to your forum user account.

    - Your account and personal data will be deleted after April 5, 2024.

    - Public posts remain, but usernames indicating real identity will be anonymized. If you disagree with a fictitious name you have the option to contact us so we can find a name that is acceptable to you.

    We hope to keep you in our community and see you on the forum soon!

    All the best

    Your Cerberus X Team

Tutorial Admob, banners and interstitials

Rob Hewitt

Active member
Tutorial Author
Joined
Aug 30, 2017
Messages
113
For my first Android Play Store release (Wormy The Worm Like Snake, please go get it. :) ) I wanted a banner ad for the title page and an interstitial for after Game Over. So after a bit of trial and error (which is why I'm writing this!) I did the following:

(This assumes that all the corrects SDKs are installed for Android eg Google Play Services)

Created an Admob account at https://apps.admob.com/admob/signup

And on this site I:

added an app under the Apps section
created a banner ad and an interstitial ad and made a note of the Ad Unit IDs

In my code in Cerberus I included the following at the top:
Code:
#ADMOB_PUBLISHER_ID="ca-app-pub-xxxxxxxxxxxxxxxx/xxxxxxxxxx"

Import mojo 
Import brl.admob
"ca-app-pub-xxxxxxxxxxxxxxxx/xxxxxxxxxx" - this is actually the Ad unit ID of the banner ad, without this no banners wil show

I then added the following under the Class
Code:
Class wormy Extends App

    ' admob bit
    Field admob:Admob
    Field interstitialAdmob:AdmobInterstitial
    Field layout:=1
    Field state:=1
(Although i think I only used the first 2 fields, they were copied from the docs example)

Under OnCreate I added:
Code:
    Method OnCreate:Int()
       
        admob=Admob.GetAdmob()
        admob.ShowAdView 1,5
    interstitialAdmob=AdmobInterstitial.GetAdmobInterstitial("ca-app-pub-xxxxxxxxxxxxxxxx/xxxxxxxxxx")
"ca-app-pub-xxxxxxxxxxxxxxxx/xxxxxxxxxx" - this is the Ad unit ID of the interstitial ad


i did call admob.ShowAdView 1,5 once at the beginning of ingame but I'm not sure if it was necessary

I also called the interstitial once at the end of the Game Over section using this code
Code:
        admob.HideAdView
        interstitialAdmob.ShowAdViewInterstitial
So that the banner would return I also created an OnResume method otherwise the banner didn't return after the interstitial:
Code:
    Method OnResume:Int()
        admob.ShowAdView 1,5
        Return 0
    End Method

As far as the coding goes, that was it. However nothing was yet displaying in the game and I had a few false starts with the IDs I needed to enter. Changing the interstitial to a test id temporarily was showing that my code was ok. Then the final things I did:

release the game
On the Admob Site added a Payment Method
linked the Play Store version of the game within the admob site. (I think that was under App Settings which allowed the Play Store to be searched and the game located.)

To test I downloaded the app from the Play Store and banners and Interstitials were now working:

Hope this helps, if I've got anything wrong (already!) let me know and I'll update this.

Cheers,

Rob
 
This is great stuff! Thanks for investing the time to write this HowTo Article.
 
I was just about too look into interstitials and this will help a lot! Thanks
 
Back
Top Bottom