googleads / googleads-consent-sdk-android

Consent SDK
https://developers.google.com/admob/android/eu-consent
Apache License 2.0
100 stars 74 forks source link

Bug: ConsentData.isRequestLocationInEeaOrUnknown is initialized to false #61

Open frevds opened 6 years ago

frevds commented 6 years ago

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.

cacti77 commented 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.

Funmungus commented 5 years ago

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.