Search in sources :

Example 11 with PersonalInfoManager

use of com.mopub.common.privacy.PersonalInfoManager in project mopub-android-mediation by mopub.

the class OguryBanner method load.

@Override
protected void load(@NonNull Context context, @NonNull AdData adData) {
    Preconditions.checkNotNull(context);
    Preconditions.checkNotNull(adData);
    final PersonalInfoManager personalInfoManager = MoPub.getPersonalInformationManager();
    if (personalInfoManager != null) {
        final boolean consentIsUnknown = personalInfoManager.getPersonalInfoConsentStatus() == ConsentStatus.UNKNOWN;
        final boolean canCollectPersonalInfo = MoPub.canCollectPersonalInformation();
        if (OguryAdapterConfiguration.initialized() && !consentIsUnknown) {
            OguryChoiceManagerExternal.setConsent(canCollectPersonalInfo, OguryAdapterConfiguration.CHOICE_MANAGER_CONSENT_ORIGIN);
        }
    }
    setAutomaticImpressionAndClickTracking(false);
    final Map<String, String> extras = adData.getExtras();
    final OguryBannerAdSize adSize = getBannerAdSize(adData.getAdWidth(), adData.getAdHeight());
    mAdUnitId = OguryAdapterConfiguration.getAdUnitId(extras);
    if (TextUtils.isEmpty(mAdUnitId) || adSize == null) {
        if (adSize == null) {
            MoPubLog.log(CUSTOM, ADAPTER_NAME, "The requested banner size does not fit " + "because Ogury only supports 320x50 and 300x250 sizes. Failing ad request.");
        }
        MoPubLog.log(getAdNetworkId(), LOAD_FAILED, ADAPTER_NAME, MoPubErrorCode.ADAPTER_CONFIGURATION_ERROR.getIntCode(), MoPubErrorCode.ADAPTER_CONFIGURATION_ERROR);
        if (mLoadListener != null) {
            mLoadListener.onAdLoadFailed(MoPubErrorCode.ADAPTER_CONFIGURATION_ERROR);
        }
        return;
    }
    mOguryAdapterConfiguration.setCachedInitializationParameters(context, extras);
    mBanner = new OguryBannerAdView(context);
    mBanner.setAdUnit(mAdUnitId);
    mBanner.setAdSize(adSize);
    mListenerHelper = new OguryAdListenerHelper(ADAPTER_NAME, mAdUnitId);
    mListenerHelper.setLoadListener(mLoadListener);
    mBanner.setListener(this);
    mBanner.setAdImpressionListener(this);
    mBanner.loadAd();
    MoPubLog.log(getAdNetworkId(), LOAD_ATTEMPTED, ADAPTER_NAME);
}
Also used : PersonalInfoManager(com.mopub.common.privacy.PersonalInfoManager) OguryBannerAdSize(com.ogury.ed.OguryBannerAdSize) OguryBannerAdView(com.ogury.ed.OguryBannerAdView)

Example 12 with PersonalInfoManager

use of com.mopub.common.privacy.PersonalInfoManager 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)12 ConsentData (com.mopub.common.privacy.ConsentData)2 ConsentStatus (com.mopub.common.privacy.ConsentStatus)2 Context (android.content.Context)1 View (android.view.View)1 EditText (android.widget.EditText)1 ListView (android.widget.ListView)1 TextView (android.widget.TextView)1 AdColonyAppOptions (com.adcolony.sdk.AdColonyAppOptions)1 NavigationView (com.google.android.material.navigation.NavigationView)1 AdvertisingId (com.mopub.common.privacy.AdvertisingId)1 OguryBannerAdSize (com.ogury.ed.OguryBannerAdSize)1 OguryBannerAdView (com.ogury.ed.OguryBannerAdView)1 OguryInterstitialAd (com.ogury.ed.OguryInterstitialAd)1 OguryOptinVideoAd (com.ogury.ed.OguryOptinVideoAd)1 MediationMetaData (com.unity3d.ads.metadata.MediationMetaData)1 MetaData (com.unity3d.ads.metadata.MetaData)1 InitCallback (com.vungle.warren.InitCallback)1 VungleSettings (com.vungle.warren.VungleSettings)1 VungleException (com.vungle.warren.error.VungleException)1