Java Code Examples for com.mopub.common.MoPub#getPersonalInformationManager()

The following examples show how to use com.mopub.common.MoPub#getPersonalInformationManager() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AppLovinCustomEventNative.java    From aptoide-client-v8 with GNU General Public License v3.0 6 votes vote down vote up
@Override public void loadNativeAd(final Context context,
    final CustomEventNativeListener customEventNativeListener,
    final Map<String, Object> localExtras, final Map<String, String> serverExtras) {
  log(DEBUG, "Requesting AppLovin native ad with server extras: " + serverExtras);

  // Pass the user consent from the MoPub SDK as per GDPR
  PersonalInfoManager personalInfoManager = MoPub.getPersonalInformationManager();
  if (personalInfoManager != null && personalInfoManager.gdprApplies()) {
    boolean canCollectPersonalInfo = personalInfoManager.canCollectPersonalInformation();
    AppLovinPrivacySettings.setHasUserConsent(canCollectPersonalInfo, context);
  }

  this.context = context;
  this.nativeListener = customEventNativeListener;

  sdk = retrieveSdk(serverExtras, context);
  sdk.setPluginVersion("MoPub-3.0.0");

  sdk.getNativeAdService()
      .loadNativeAds(1, this);
}
 
Example 2
Source File: MoPubConsentManager.java    From aptoide-client-v8 with GNU General Public License v3.0 6 votes vote down vote up
@Override public void showConsentDialog() {
  PersonalInfoManager personalInfoManager = MoPub.getPersonalInformationManager();
  personalInfoManager.loadConsentDialog(new ConsentDialogListener() {
    @Override public void onConsentDialogLoaded() {
      if (personalInfoManager != null
          && personalInfoManager.isConsentDialogReady()
          && !wasMoPubConsentDialogShown) {
        wasMoPubConsentDialogShown = true;
        personalInfoManager.showConsentDialog();
      }
    }

    @Override public void onConsentDialogLoadFailed(@NonNull MoPubErrorCode moPubErrorCode) {
      Logger.getInstance()
          .d("MoPubConsent",
              "MoPub Consent dialog failed to load due to " + moPubErrorCode.toString());
    }
  });
}
 
Example 3
Source File: AppLovinCustomEventNative.java    From SDK-Network-Adapters with MIT License 6 votes vote down vote up
@Override
public void loadNativeAd(final Context context, final CustomEventNativeListener customEventNativeListener, final Map<String, Object> localExtras, final Map<String, String> serverExtras)
{
    log( DEBUG, "Requesting AppLovin native ad with server extras: " + serverExtras );

    // Pass the user consent from the MoPub SDK as per GDPR
    PersonalInfoManager personalInfoManager = MoPub.getPersonalInformationManager();
    if ( personalInfoManager != null && personalInfoManager.gdprApplies() )
    {
        boolean canCollectPersonalInfo = personalInfoManager.canCollectPersonalInformation();
        AppLovinPrivacySettings.setHasUserConsent( canCollectPersonalInfo, context );
    }

    this.context = context;
    this.nativeListener = customEventNativeListener;

    sdk = retrieveSdk( serverExtras, context );
    sdk.setPluginVersion( "MoPub-3.0.0" );

    sdk.getNativeAdService().loadNativeAds( 1, this );
}
 
Example 4
Source File: MoPubConsentManager.java    From aptoide-client-v8 with GNU General Public License v3.0 4 votes vote down vote up
@Override public Single<Boolean> shouldShowConsentDialog() {
  PersonalInfoManager personalInfoManager = MoPub.getPersonalInformationManager();
  return Single.just(personalInfoManager.shouldShowConsentDialog());
}
 
Example 5
Source File: AppLovinCustomEventRewardedVideo.java    From SDK-Network-Adapters with MIT License 4 votes vote down vote up
@Override
protected void loadWithSdkInitialized(@NonNull final Activity activity, @NonNull final Map<String, Object> localExtras, @NonNull final Map<String, String> serverExtras) throws Exception
{
    log( DEBUG, "Requesting AppLovin banner with serverExtras: " + serverExtras + " and localExtras: " + localExtras );

    // Pass the user consent from the MoPub SDK as per GDPR
    PersonalInfoManager personalInfoManager = MoPub.getPersonalInformationManager();
    if ( personalInfoManager != null && personalInfoManager.gdprApplies() )
    {
        boolean canCollectPersonalInfo = personalInfoManager.canCollectPersonalInformation();
        AppLovinPrivacySettings.setHasUserConsent( canCollectPersonalInfo, activity.getApplicationContext() );
    }

    parentActivity = activity;

    // Zones support is available on AppLovin SDK 7.5.0 and higher
    final String zoneId;
    if ( AppLovinSdk.VERSION_CODE >= 750 && serverExtras != null && serverExtras.containsKey( "zone_id" ) )
    {
        zoneId = serverExtras.get( "zone_id" );
    }
    else
    {
        zoneId = DEFAULT_ZONE;
    }


    // Check if incentivized ad for zone already exists
    if ( GLOBAL_INCENTIVIZED_INTERSTITIAL_ADS.containsKey( zoneId ) )
    {
        incentivizedInterstitial = GLOBAL_INCENTIVIZED_INTERSTITIAL_ADS.get( zoneId );
    }
    else
    {
        // If this is a default Zone, create the incentivized ad normally
        if ( DEFAULT_ZONE.equals( zoneId ) )
        {
            incentivizedInterstitial = AppLovinIncentivizedInterstitial.create( activity );
        }
        // Otherwise, use the Zones API
        else
        {
            incentivizedInterstitial = AppLovinIncentivizedInterstitial.create( zoneId, sdk );
        }

        GLOBAL_INCENTIVIZED_INTERSTITIAL_ADS.put( zoneId, incentivizedInterstitial );
    }

    incentivizedInterstitial.preload( this );
}
 
Example 6
Source File: AppLovinCustomEventInterstitial.java    From SDK-Network-Adapters with MIT License 4 votes vote down vote up
@Override
public void loadInterstitial(final Context context, final CustomEventInterstitialListener listener, final Map<String, Object> localExtras, final Map<String, String> serverExtras)
{
    log( DEBUG, "Requesting AppLovin interstitial with serverExtras: " + serverExtras + " and localExtras: " + localExtras );

    // SDK versions BELOW 7.2.0 require a instance of an Activity to be passed in as the context
    if ( AppLovinSdk.VERSION_CODE < 720 && !( context instanceof Activity ) )
    {
        log( ERROR, "Unable to request AppLovin banner. Invalid context provided." );
        listener.onInterstitialFailed( MoPubErrorCode.ADAPTER_CONFIGURATION_ERROR );

        return;
    }

    // Pass the user consent from the MoPub SDK as per GDPR
    PersonalInfoManager personalInfoManager = MoPub.getPersonalInformationManager();
    if ( personalInfoManager != null && personalInfoManager.gdprApplies() )
    {
        boolean canCollectPersonalInfo = personalInfoManager.canCollectPersonalInformation();
        AppLovinPrivacySettings.setHasUserConsent( canCollectPersonalInfo, context );
    }

    // Store parent objects
    this.listener = listener;
    this.context = context;

    sdk = retrieveSdk( serverExtras, context );
    sdk.setPluginVersion( "MoPub-3.0.0" );

    // Zones support is available on AppLovin SDK 7.5.0 and higher
    final String serverExtrasZoneId = serverExtras != null ? serverExtras.get( "zone_id" ) : null;
    zoneId = ( !TextUtils.isEmpty( serverExtrasZoneId ) && AppLovinSdk.VERSION_CODE >= 750 ) ? serverExtrasZoneId : DEFAULT_ZONE;

    // Check if we already have a preloaded ad for the given zone
    final AppLovinAd preloadedAd = dequeueAd( zoneId );
    if ( preloadedAd != null )
    {
        log( DEBUG, "Found preloaded ad for zone: {" + zoneId + "}" );
        adReceived( preloadedAd );
    }
    else
    {
        // If this is a default Zone, create the incentivized ad normally
        if ( DEFAULT_ZONE.equals( zoneId ) )
        {
            sdk.getAdService().loadNextAd( AppLovinAdSize.INTERSTITIAL, this );
        }
        // Otherwise, use the Zones API
        else
        {
            sdk.getAdService().loadNextAdForZoneId( zoneId, this );
        }
    }
}