Sub Globals
'These global variables will be redeclared each time the activity is created.
'These variables can only be accessed from this module.
Public consent As ConsentManager
Dim AdView1 As AdView
End Sub
'show the consent form if needed
Sub ConsentStateAvailable
consent = Starter.consent
If consent.ConsentState = consent.STATE_UNKNOWN And consent.IsRequestLocationInEeaOrUnknown Then
'Set last parameter to False if you don't want to show the "pay for ad-free" option.
'Change privacy policy URL.
'Sleep(5000)
Log("a")
consent.ShowConsentForm("https://www.google.com/policies/technologies/partner-sites/", True, True, False)
'Sleep(5000)
Log("b")
Wait For Consent_FormResult (Success As Boolean, UserPrefersAdFreeOption As Boolean)
'Sleep(5000)
Log("b")
If Success Then
Log($"Consent form result: ${consent.ConsentState}, AdFree: ${UserPrefersAdFreeOption}"$)
Else
Log($"Errore: ${LastException}"$)
End If
End If
LoadAd
End Sub
'load ads:
Sub LoadAd
Dim builder As AdRequestBuilder
builder.Initialize
If consent.IsRequestLocationInEeaOrUnknown Then
If consent.ConsentState = consent.STATE_NON_PERSONALIZED Then
builder.NonPersonalizedAds
Else if consent.ConsentState = consent.STATE_UNKNOWN Then
Return
End If
End If
'builder.AddTestDevice("D4AC977CA12D122C4563730CC762C302")
'adview1.LoadAdWithBuilder(builder)
AdView1.Initialize2("AdView1","ca-app-pub-3737348979012626/9909374758", AdView1.SIZE_SMART_BANNER)
Activity.AddView(AdView1, 0, 100%y -50dip, 100%x, 50dip)
AdView1.LoadAdWithBuilder(builder)
AdView1.Visible = True
End Sub