Skip to content

Commit

Permalink
Merge pull request #273 from prebid/MS-4877_InApp_Native_fix
Browse files Browse the repository at this point in the history
Fix: Issue #271 - InApp Native
  • Loading branch information
avohraa authored Nov 2, 2021
2 parents 9053699 + 12c27d2 commit d2e0c47
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ private Constants() {
static final String PBS_CONFIG_ID_300x250_APPNEXUS = "6ace8c7d-88c0-4623-8117-75bc3f0a2e45";
static final String PBS_CONFIG_ID_320x50_APPNEXUS = "625c6125-f19e-4d5b-95c5-55501526b2a4";
static final String PBS_CONFIG_ID_INTERSTITIAL_APPNEXUS = "625c6125-f19e-4d5b-95c5-55501526b2a4";
static final String PBS_CONFIG_ID_NATIVE_APPNEXUS = "25e17008-5081-4676-94d5-923ced4359d3";
static final String PBS_CONFIG_ID_NATIVE_APPNEXUS = "03f3341f-1737-402c-bc7d-bc81dfebe9cf"; // 25e17008-5081-4676-94d5-923ced4359d3
// MoPub ad unit ids
static final String MOPUB_BANNER_ADUNIT_ID_300x250_APPNEXUS = "a935eac11acd416f92640411234fbba6";
static final String MOPUB_BANNER_ADUNIT_ID_320x50_APPNEXUS = "9dbccb87ab4d4a178450c0bc986b4571";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,14 @@ protected void onCreate(Bundle savedInstanceState) {
loadInAppNative();
}

private void setupNativePremium() {
Host custom = Host.CUSTOM;
custom.setHostUrl("https://ib.adnxs.com/openrtb2/prebid");
PrebidMobile.setPrebidServerHost(custom);
PrebidMobile.setPrebidServerAccountId("9325"); //1601
NativeAdUnit nativeAdUnit = new NativeAdUnit("18491617"); //22650327
}

private void loadInAppNative() {
removePreviousAds();
PrebidMobile.setPrebidServerHost(Host.APPNEXUS);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ class NativeRequestParams {
static String DATA = "data";
static String NATIVE = "native";
static String REQUEST = "request";
static final String ID = "id";

private NativeAdUnit.CONTEXT_TYPE contextType;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,8 @@ public static boolean isShareGeoLocation() {
}

private static List<ExternalUserId> externalUserIds = new ArrayList<>();

private static boolean assignNativeAssetID = false;
/**
* List containing objects that hold External UserId parameters for the current application user.
* @param externalUserIds
Expand Down Expand Up @@ -148,4 +150,19 @@ public static boolean getPbsDebug() {
public static void setPbsDebug(boolean pbsDebug) {
PrebidMobile.pbsDebug = pbsDebug;
}

/**
* @return boolean that states if the ID will be set to the Asset array (in the Native Ad Request)
* This value can be set using the {@link #assignNativeAssetID(boolean)}
* */
public static boolean shouldAssignNativeAssetID() {
return assignNativeAssetID;
}

/**
* For assigning ID to the Assets in the Asset array (in Native Ad Request)
* */
public static void assignNativeAssetID(boolean assignNativeAssetID) {
PrebidMobile.assignNativeAssetID = assignNativeAssetID;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -508,6 +508,7 @@ public Integer apply(Signals.Api element) {
request.put(NativeRequestParams.PRIVACY, params.isPrivacy() ? 1 : 0);
request.put(NativeRequestParams.EXT, params.getExt());
if (!params.getAssets().isEmpty()) {
int idCount = 1;
for (NativeAsset asset : params.getAssets()) {
JSONObject assetObj;
switch (asset.getType()) {
Expand All @@ -522,6 +523,9 @@ public Integer apply(Signals.Api element) {
assetObj.put(NativeRequestParams.TITLE, title);
assetObj.put(NativeRequestParams.REQUIRED, titleAsset.isRequired() ? 1 : 0);
assetObj.put(NativeRequestParams.EXT, titleAsset.getAssetExt());
if (PrebidMobile.shouldAssignNativeAssetID()) {
assetObj.put(NativeRequestParams.ID, idCount++);
}
assets.put(assetObj);
break;
case IMAGE:
Expand Down Expand Up @@ -550,6 +554,9 @@ public Integer apply(Signals.Api element) {
assetObj.put(NativeRequestParams.IMAGE, image);
assetObj.put(NativeRequestParams.REQUIRED, imageAsset.isRequired() ? 1 : 0);
assetObj.put(NativeRequestParams.EXT, imageAsset.getAssetExt());
if (PrebidMobile.shouldAssignNativeAssetID()) {
assetObj.put(NativeRequestParams.ID, idCount++);
}
assets.put(assetObj);
break;
case DATA:
Expand All @@ -566,6 +573,9 @@ public Integer apply(Signals.Api element) {
assetObj.put(NativeRequestParams.DATA, data);
assetObj.put(NativeRequestParams.REQUIRED, dataAsset.isRequired() ? 1 : 0);
assetObj.put(NativeRequestParams.EXT, dataAsset.getAssetExt());
if (PrebidMobile.shouldAssignNativeAssetID()) {
assetObj.put(NativeRequestParams.ID, idCount++);
}
assets.put(assetObj);

break;
Expand Down

0 comments on commit d2e0c47

Please sign in to comment.