Hello my friends,
I embed code for GDPR and User Consent from @Erel Tutorial. I figured out that when i accept to show relative ads, banner ads with android 8 does not show any ads. Interistitial ads shows correctly. If i choose NOT to show relevant ads, banner ads and interistitial are shown correctly. All these happens at android emulator with sdk 27.
If i try on a physical device with 27 sdk, it happens again same, but now when i hit NOT to show relevant ads. Update: Now, on a physical device does not show banner ad at all answers.
p.s. Error code: 3
p.s.1 all sdk and lib files are updated
I embed code for GDPR and User Consent from @Erel Tutorial. I figured out that when i accept to show relative ads, banner ads with android 8 does not show any ads. Interistitial ads shows correctly. If i choose NOT to show relevant ads, banner ads and interistitial are shown correctly. All these happens at android emulator with sdk 27.
p.s. Error code: 3
p.s.1 all sdk and lib files are updated
B4X:
Sub ads
Dim builder As AdRequestBuilder
builder.Initialize
Dim consent As ConsentManager = Starter.consent
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
AdView1.Initialize2("Ad", "ca-app-pub-4939954923862155/3607161653", AdView1.SIZE_SMART_BANNER)
Dim AdMobHeight As Int
Dim ScreenHeightScaled As Float
ScreenHeightScaled = GetDeviceLayoutValues.Height / GetDeviceLayoutValues.Scale
' Ad height 32dip: device screen height <= 400
' Ad height 50dip: 400 < device screen height <= 720
' Ad height 90dip: device screen height > 720
If ScreenHeightScaled <= 400 Then
AdMobHeight = 32dip
Else if ScreenHeightScaled > 400 And ScreenHeightScaled <= 720 Then
AdMobHeight = 50dip
Else if ScreenHeightScaled > 720 Then
AdMobHeight = 90dip
End If
pnlButtons.Top=100%y-AdMobHeight-pnlButtons.height
pnlMain.height=pnlButtons.Top-pnlMain.Top
Activity.AddView(AdView1, 0dip,pnlButtons.Top+pnlButtons.height,100%x,AdMobHeight)
'Activity.AddView(AdView1, 0, 0, 320dip, 50dip)
AdView1.LoadAdWithBuilder(builder)
IAd.Initialize("iad","ca-app-pub-4939954923862155/2150483968")
IAd.LoadAdWithBuilder(builder)
End Sub
B4X:
'show the consent form if needed
Sub ConsentStateAvailable
Dim consent As ConsentManager = 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.
consent.ShowConsentForm("https://policies.google.com/technologies/partner-sites", True, True, False)
Wait For Consent_FormResult (Success As Boolean, UserPrefersAdFreeOption As Boolean)
If Success Then
Log($"Consent form result: ${consent.ConsentState}, AdFree: ${UserPrefersAdFreeOption}"$)
'If UserPrefersAdFreeOption Then CallSubDelayed(Me,"subscription")
Else
Log($"Error: ${LastException}"$)
End If
End If
End Sub
B4X:
Sub Service_Create
consent.Initialize("consent")
'consent.AddTestDevice("D4AC977CA12D122C4563730CC762C302")
'consent.SetDebugGeography(True) 'comment for regular operation
consent.RequestInfoUpdate(Array("pub-4939954923862155"))
Wait For consent_InfoUpdated (Success As Boolean)
If Success = False Then
Log($"Error getting consent state: ${LastException}"$)
End If
Log($"Consent state: ${consent.ConsentState}"$)
Log("EU: " & consent.IsRequestLocationInEeaOrUnknown)
Do While IsPaused(Main)
Sleep(100)
Loop
CallSubDelayed(Main, "ConsentStateAvailable")
End Sub
Last edited: