• 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

Admob help

Wingnut

Well-known member
3rd Party Module Dev
Tutorial Author
Joined
Jan 2, 2020
Messages
1,414
Please can someone guide me how do I get the example to work?
It keep telling me "identifier ShowAd not found."

Code:
#If TARGET<>"android" And TARGET<>"ios"
#Error "Admob is only supported on Android and iOS targets"
#End

#ADMOB_PUBLISHER_ID="ca-app-pub-3940256099942544/6300978111"    'replace with id from your admob account
#ADMOB_ANDROID_TEST_DEVICE1="TEST_EMULATOR"
#ADMOB_ANDROID_TEST_DEVICE2="TEST_EMULATOR"

Import mojo
Import brl.admob

Class MyApp Extends App

  Field admob:Admob
  Field interstitialAdmob:AdmobInterstitial
  Field layout:=1
  Field state:=1

  Method OnCreate()
    admob=Admob.GetAdmob()
    admob.ShowAdView 1,layout
    interstitialAdmob=AdmobInterstitial.GetAdmobInterstitial("ca-app-pub-3940256099942544/1033173712")
    SetUpdateRate 60
  End

  Method OnUpdate()
    If MouseHit( 0 )
      If state = 3
        admob.HideAdView
        state+=1
      Else If state = 1
        layout+=1
        If layout=7 layout=1
        admob.ShowAdView 1,layout
        state+=1
      Else If state = 2
        admob.HideAdView
        interstitialAdmob.ShowAd
        state+=1
      End
    End
  End

  Method OnRender()
    Local en:="disabled"
    If state=2 en="enabled"
    Cls
    PushMatrix
      Scale 2,2
      DrawText "Click to toggle ads! ads are currently "+en,DeviceWidth/4,DeviceHeight/4,.5,.5
    PopMatrix
  End

End

Function Main()
  New MyApp
End
 
That's probably an outdated example. For interstitial ads use: ShowAdViewInterstitial

So replace
Code:
interstitialAdmob.ShowAd
with
Code:
interstitialAdmob.ShowAdViewInterstitial
 
Thanks, but it just gives me a black screen, did I put the id correctly though bc mine looks different than the one in the example, the intertestial id had the same format though so I'm fairly confident that one is correctly made.

my id goes like this #ADMOB_PUBLISHER_ID="pub-################"
I tried adding "ca-" in the beginning but still black screen.
 
Last edited:
TBH I never tried interstitial ads. Does the test ad show up?
 
I don't have a Android device to try out on any more for today. I never tried the default ID I will as soon as I can.
 
It had a slash in its ID.. very weird?

I see that you can "Add test device" in their website, maybe that's what is missing for me?
 
No, you don't have to add test devices. Would have to check, all I know is that the look of their IDs have changed lately.

Mine (working one) looks like that for instance:
Code:
#ADMOB_PUBLISHER_ID="ca-app-pub-69037177xxxxxxxx/9125xxxxxx"
 
When i get the howto instructions I find this :

"To place the ad unit inside your app, follow these instructions:
Complete the instructions in the Google Mobile Ads SDK guide using this app ID:

Demo app
ca-app-pub-################~##########
Follow the interstitial implementation guide to integrate the SDK. You'll specify ad type and placement when you integrate the code using this ad unit ID:

demoad
ca-app-pub-################/##########
Review the AdMob policies to ensure your implementation complies."


Maybe ca-app-pub-################~########## is the new format of publisher ID (actually App-ID, but Isn't that was is wanted, Publisher ID is really short?). I wish I had an device to try on right now.
 
Last edited:
Well be careful with that '~'. I know it's part of the ID now? In Monkey/Cerberus it's the escape sequence (so like normally '\').

So to encode that '~' itself you have to write '~~'

But yeah, without a real device it's impossible to see if it really works.
 
Thanks. You were ahead of me regarding the tilde. Will test when possible!
 
All I can say is that with real ads at least on my side it could take up to 24h until they really showed up! So it's save to assume that it works when the test ads are working. But again - that's on a real device and I don't know it interstitial banners currently work, I just tried classic banners.
 
How would you get normal banners I don't see an example for that?
 
Oh that's done in that example as well:

Code:
admob.ShowAdView 1,layout

in my particular game:
Code:
Class MauMau Extends App
  #If TARGET="ios" Or TARGET="android"
    Field _admob:Admob
    Field _layout:Int = 5
    Field _enabled:Bool = True
  #End

  Method OnCreate:Int()
  ...
    #If TARGET="ios" Or TARGET="android"
      _admob = Admob.GetAdmob()
      If( gIsFullVersion )
        _admob.HideAdView()
      Else
        _admob.ShowAdView( 2, _layout )
      End If
    #End
    Return 0
  End Method

...
 
Is Admob fully compatible with Mojo2?
 
I think so. Because it's already above all that stuff, it's view/layout based so doesn't care about the canvas. It's like an own frame on top.
 
Nothing worked, not even the standard demo. Before i *DID* get a banner this was way back like 6 months or so. but when you clicke again it deissapeared for good (which it shouldnt if i uunderstood the demo).

But now this time... nothing. I tried both kinds of ads for mine, and the standard demo.
 
I think the SDK needs to be updated. Android has quite a few changes these days. Definitely needs to be looked into before the next release.
 
Back
Top Bottom