public GdprHelper(Context context) {
this.context = context;
}
public void initialise() {
ConsentInformation consentInformation = ConsentInformation.getInstance(context);
consentInformation.addTestDevice(PUBLISHER_ID);
consentInformation.setDebugGeography(DebugGeography.DEBUG_GEOGRAPHY_EEA);
consentInformation.requestConsentInfoUpdate(new String[]{PUBLISHER_ID}, new ConsentInfoUpdateListener() {
@Override
public void onConsentInfoUpdated(ConsentStatus consentStatus) {
if(consentStatus == ConsentStatus.UNKNOWN){
displayConsentForm();
}
}
@Override
public void onFailedToUpdateConsentInfo(String errorDescription) {
Dlog.e("errorDescription : " + errorDescription);
}
});
}
private void displayConsentForm() {
consentForm = new ConsentForm.Builder(context, getPrivacyUrl())
.withListener(new ConsentFormListener() {
@Override
public void onConsentFormLoaded() {
consentForm.show();
}
@Override
public void onConsentFormOpened() {
}
@Override
public void onConsentFormClosed(
ConsentStatus consentStatus, Boolean userPrefersAdFree) {
}
@Override
public void onConsentFormError(String errorDescription) {
Dlog.e("errorDescription : " + errorDescription);
}
})
.withPersonalizedAdsOption()
.withNonPersonalizedAdsOption()
.withAdFreeOption()
.build();
consentForm.load();
}
private URL getPrivacyUrl() {
URL privacyUrl = null;
try {
privacyUrl = new URL(PRIVACY_URL);
} catch (MalformedURLException e) {
e.printStackTrace();
}
return privacyUrl;
}
private void redirectToPaidVersion() {
Intent i = new Intent(
Intent.ACTION_VIEW,
Uri.parse(MARKET_URL_PAID_VERSION));
context.startActivity(i);
}
public void resetConsent() {
ConsentInformation consentInformation = ConsentInformation.getInstance(context);
consentInformation.reset();
}
GDPR 클래스인데 분명 아래 코드로 EEA 설정 했는데 Error: request is not in EEA or unknown. 에러가 뜹니다.
consentInformation.setDebugGeography(DebugGeography.DEBUG_GEOGRAPHY_EEA);