- Joined
- Jan 2, 2020
- Messages
- 1,414
Today I couldn't get my personal account to show ads, but that's probably a separate issue, the demo does show.
I made a slim version that includes the knowledge of this whole thread, and also converts it into Mojo2.
(for the record, it behaves exactly the same under Mojo1)
I made a slim version that includes the knowledge of this whole thread, and also converts it into Mojo2.
(for the record, it behaves exactly the same under Mojo1)
Code:
' Google Admob test ads example
' App description as it appears :
' Starting with black screen, says disabled, loading the first banner (takes a sec)
' 1) showing banner (top left) (still says disabled)
' 2) showing banner (top middle (says enabled)
' 3) showing fullscreen (interstitial) (says disabled just before being shown)
' 4) showing banner (bottom middle) (says disabled)
' Then nothing (continuing saying disabled, it and uses 0 traffic from now on, stuck here)
#ANDROID_LOGCAT_OPTION="-s [Cerberus]:E"
Import mojo2
Import brl.admob
Function Main()
New MyApp
End
#ADMOB_ANDROID_ADS_APPID = "ca-app-pub-3940256099942544~~3347511713" ' App id.
#ADMOB_PUBLISHER_ID = "ca-app-pub-3940256099942544/6300978111" ' Banner-ad id.
Class MyApp Extends App
Field admob:Admob
Field interstitialAdmob:AdmobInterstitial
Field layout:Int = 1 ' Layouts 1 - 6
Field state:Int = 1
Field canvas:Canvas
Method OnCreate()
canvas = New Canvas()
admob=Admob.GetAdmob()
admob.ShowAdView 1,layout
interstitialAdmob = AdmobInterstitial.GetAdmobInterstitial("ca-app-pub-3940256099942544/1033173712") ' Interstitial-ad id.
SetSwapInterval 1 ; SetUpdateRate 0
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.ShowAdViewInterstitial
state+=1
End
End
End
Method OnRender()
Local en:="disabled"
If state=2 en="enabled"
canvas.Clear
canvas.PushMatrix
canvas.Scale 2,2
canvas.DrawText "Click to toggle ads! ads are currently "+en,DeviceWidth/4,DeviceHeight/4,.5,.5
canvas.PopMatrix
canvas.Flush
End
Method OnResume:Int() ' Resume from interstitial-ad.
admob.ShowAdView 1,5
Return 0
End Method
End
Last edited: