Open frevds opened 6 years ago
I don't think this is a bug. If you look at https://developers.google.com/admob/android/eu-consent#update_consent_status it says:
Once consent information is successfully updated, you can also check ConsentInformation.getInstance(context).isRequestLocationInEeaOrUnknown() to see if the user is located in the European Economic Area or the request location is unknown.
In other words you shouldn't call isRequestLocationInEeaOrUnknown()
unless you're inside onConsentInfoUpdated()
. That's what I do, and it appears to work fine.
I agree the docs/code snippets could be clearer on this.
This affected me as well. I followed the documentation to show a consent form only if isRequestLocationInEeaOrUnknown
. While debugging I use setDebugLocation
to confirm the form will show without errors. Even right after calling setDebugLocation
it was always false until requestConsentInfoUpdate
was called. Interestingly though, setDebugLocation
does work at any point in my Activity, given you only use isRequestLocationInEeaOrUnknown
as @cacti77 has mentioned above.
ConsentInformation.isRequestLocationInEeaOrUnknown returns false if requestConsentInfoUpdate was 1) not called or 2) did not succeed.
This is because ConsentData.isRequestLocationInEeaOrUnknown is set to false in its constructor, which is plainly wrong, as it is unknown at this moment.