Search in sources :

Example 1 with MetaData

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();
    }
}
Also used : PersonalInfoManager(com.mopub.common.privacy.PersonalInfoManager) MetaData(com.unity3d.ads.metadata.MetaData) MediationMetaData(com.unity3d.ads.metadata.MediationMetaData)

Aggregations

PersonalInfoManager (com.mopub.common.privacy.PersonalInfoManager)1 MediationMetaData (com.unity3d.ads.metadata.MediationMetaData)1 MetaData (com.unity3d.ads.metadata.MetaData)1