Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added capability to get Publisher provided extras from InMobi Adapter #679

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ public class InMobiMediationAdapter
{
private static final String KEY_PARTNER_GDPR_CONSENT = "partner_gdpr_consent_available";
private static final String KEY_PARTNER_GDPR_APPLIES = "partner_gdpr_applies";
private static final String INMOBI_EXTRA_KEY = "inmobi";

// https://support.inmobi.com/monetize/android-guidelines/native-ads-for-android/#set-up-native-ad
// The default setting is an in-Feed ad layout, an aspect ratio ranging between 256:135 - 1200x627
Expand Down Expand Up @@ -509,7 +510,7 @@ private Map<String, String> getExtras(MaxAdapterParameters parameters)
Map<String, String> extras = new HashMap<>( 3 );
extras.put( "tp", "c_applovin" );
extras.put( "tp-ver", AppLovinSdk.VERSION );

extras.putAll(getPublisherProvidedExtras(parameters));
Boolean isAgeRestrictedUser = parameters.isAgeRestrictedUser();
if ( isAgeRestrictedUser != null )
{
Expand Down Expand Up @@ -567,6 +568,33 @@ private MaxNativeAdView createMaxNativeAdView(final MaxNativeAd maxNativeAd, fin
}
}

private Map<String, String> getPublisherProvidedExtras(MaxAdapterParameters parameters) {
try {
Object extraData = parameters.getLocalExtraParameters().get(INMOBI_EXTRA_KEY);
if (extraData == null) {
return new HashMap<>();
}
HashMap<String, String> pubSuppliedExtras = new HashMap<>();
if (extraData instanceof Map) {
Map<?, ?> extraData1 = (Map<?, ?>) extraData;
for (Map.Entry<?, ?> entry : extraData1.entrySet()) {
if (entry.getKey() == null || entry.getValue() == null) {
continue;
}
if (entry.getKey() instanceof String && entry.getValue() instanceof String) {
pubSuppliedExtras.put((String) entry.getKey(), (String) entry.getValue());
}
}
} else {
log("Provided extras is not a Map");
}
return pubSuppliedExtras;
} catch (Exception exception) {
log("Failed to get Pub Supplied extras", exception);
return new HashMap<>();
}
}

private static MaxAdapterError toMaxError(InMobiAdRequestStatus inMobiError)
{
final InMobiAdRequestStatus.StatusCode inMobiErrorCode = inMobiError.getStatusCode();
Expand Down