use of com.unity3d.ads.metadata.MetaData in project mopub-android-mediation by mopub.
the class UnityAdsInitializer method initGdpr.
private void initGdpr(Context context) {
// Pass the user consent from the MoPub SDK to Unity Ads as per GDPR
PersonalInfoManager personalInfoManager = MoPub.getPersonalInformationManager();
final boolean canCollectPersonalInfo = MoPub.canCollectPersonalInformation();
final boolean shouldAllowLegitimateInterest = MoPub.shouldAllowLegitimateInterest();
if (personalInfoManager != null && personalInfoManager.gdprApplies() == Boolean.TRUE) {
final MetaData gdprMetaData = new MetaData(context);
if (shouldAllowLegitimateInterest) {
if (personalInfoManager.getPersonalInfoConsentStatus() == ConsentStatus.EXPLICIT_NO || personalInfoManager.getPersonalInfoConsentStatus() == ConsentStatus.DNT) {
gdprMetaData.set("gdpr.consent", false);
} else {
gdprMetaData.set("gdpr.consent", true);
}
} else {
gdprMetaData.set("gdpr.consent", canCollectPersonalInfo);
}
gdprMetaData.commit();
}
}
Aggregations