Search in sources :

Example 1 with VungleSettings

use of com.vungle.warren.VungleSettings in project mopub-android-mediation by mopub.

the class VungleRouter method initVungle.

void initVungle(final Context context, final String vungleAppId) {
    // Pass the user consent from the MoPub SDK to Vungle as per GDPR
    // Pass consentMessageVersion per Vungle 6.3.17:
    // https://support.vungle.com/hc/en-us/articles/360002922871#GDPRRecommendedImplementationInstructions
    InitCallback initCallback = new InitCallback() {

        @Override
        public void onSuccess() {
            MoPubLog.log(CUSTOM, ADAPTER_NAME, "SDK is initialized successfully.");
            sInitState = SDKInitState.INITIALIZED;
            clearWaitingList();
            // Pass the user consent from the MoPub SDK to Vungle as per GDPR
            PersonalInfoManager personalInfoManager = MoPub.getPersonalInformationManager();
            boolean canCollectPersonalInfo = MoPub.canCollectPersonalInformation();
            boolean shouldAllowLegitimateInterest = MoPub.shouldAllowLegitimateInterest();
            if (personalInfoManager != null && personalInfoManager.gdprApplies() == Boolean.TRUE) {
                if (shouldAllowLegitimateInterest) {
                    if (personalInfoManager.getPersonalInfoConsentStatus() == ConsentStatus.EXPLICIT_NO || personalInfoManager.getPersonalInfoConsentStatus() == ConsentStatus.DNT || personalInfoManager.getPersonalInfoConsentStatus() == ConsentStatus.POTENTIAL_WHITELIST) {
                        Vungle.updateConsentStatus(Vungle.Consent.OPTED_OUT, "");
                    } else {
                        Vungle.updateConsentStatus(Vungle.Consent.OPTED_IN, "");
                    }
                } else {
                    // Pass consentMessageVersion per Vungle 6.3.17:
                    // https://support.vungle.com/hc/en-us/articles/360002922871#GDPRRecommendedImplementationInstructions
                    Vungle.updateConsentStatus(canCollectPersonalInfo ? Vungle.Consent.OPTED_IN : Vungle.Consent.OPTED_OUT, "");
                }
            }
        }

        @Override
        public void onError(VungleException throwable) {
            MoPubLog.log(CUSTOM_WITH_THROWABLE, "Initialization failed.", throwable);
            sInitState = SDKInitState.NOTINITIALIZED;
        }

        @Override
        public void onAutoCacheAdAvailable(String placementId) {
        // no-op
        }
    };
    VungleSettings vungleSettings = VungleNetworkSettings.getVungleSettings();
    VungleSettings settings = (vungleSettings != null) ? vungleSettings : new VungleSettings.Builder().build();
    Vungle.init(vungleAppId, context.getApplicationContext(), initCallback, settings);
    sInitState = SDKInitState.INITIALIZING;
}
Also used : InitCallback(com.vungle.warren.InitCallback) VungleSettings(com.vungle.warren.VungleSettings) PersonalInfoManager(com.mopub.common.privacy.PersonalInfoManager) VungleException(com.vungle.warren.error.VungleException)

Aggregations

PersonalInfoManager (com.mopub.common.privacy.PersonalInfoManager)1 InitCallback (com.vungle.warren.InitCallback)1 VungleSettings (com.vungle.warren.VungleSettings)1 VungleException (com.vungle.warren.error.VungleException)1