Sub getConsent
consent.Initialize("consent")
consent.LogDeviceIdForDebugging
consent.AddTestDevice("xxxxxxx-144E-45D6-9651-834C645DE093")
consent.SetDebugGeography(True) 'comment for regular operation
consent.RequestInfoUpdate(Array("pub-xxxxxxxxxxxxxxxx"))
Wait For consent_InfoUpdated (Success As Boolean)
If Success = False Then
Log($"Error getting consent state: ${LastException}"$)
End If
Log($"Consent state: ${consent.ConsentState}"$) '0 - UNKNOWN, 1 - NON_PERSONALIZED, 2 - PERSONALIZED
Log(consent.IsRequestLocationInEeaOrUnknown)
ConsentStateAvailable
End Sub
Sub ConsentStateAvailable
If consent.ConsentState = consent.STATE_UNKNOWN And consent.IsRequestLocationInEeaOrUnknown Then
consent.ShowConsentForm(B4XPages.GetNativeParent(Me), "https://www.nsobol.com/privacy-policy.html", True, True, True)
Wait For Consent_FormResult (Success As Boolean, UserPrefersAdFreeOption As Boolean)
If Success Then
Log($"Consent form result: ${consent.ConsentState}, AdFree: ${UserPrefersAdFreeOption}"$)
Else
Log($"Error: ${LastException}"$)
End If
End If
End Sub