{"_id":"5cac2b62ac9ae90034e940bc","project":"5429beef1163360800ed31fa","version":{"_id":"5429beef1163360800ed31fd","__v":22,"project":"5429beef1163360800ed31fa","createdAt":"2014-09-29T20:19:59.904Z","releaseDate":"2014-09-29T20:19:59.904Z","categories":["5429beef1163360800ed31fe","55e74e1f5d36b32b002563fa","55e7500a73169617001f2e86","55e76b8196131b2f00bf4b72","55e89569cdbb8a350096df9c","55f8935eb089b71700a8364e","55f8a67d3bb4bb0d0022d093","55f9dbefc7ef770d00d9bf6d","5601c21a22ecf60d002b27b3","5601c21ff12aee0d001bb06e","5601c2256c7b610d00280db5","5601c22c22ecf60d002b27b4","5603738d0c78b00d0039af47","5626f70bfcbbc621004ebf52","566f7a1ae144ab0d00e9732f","566f85ca7820960d00c3b93d","56708ce43a32d20d00c45cbf","56708d436995210d003aad8e","5736471abe10a9200030732c","57a82c7aff9bd30e00a6f1c1","591b8500e3992319007190f4","5a3718305c66a60012d960ba"],"is_deprecated":false,"is_hidden":false,"is_beta":false,"is_stable":true,"codename":"","version_clean":"1.0.0","version":"1.0"},"category":{"_id":"5601c22c22ecf60d002b27b4","pages":["5601d37b70694e0d00e3c67e","5601d3a0d3ffde0d006abbd0","5601d3fd96e0f70d0044b110","5601d42096e0f70d0044b112","5601d45d7435de0d00fabc27","5601d48170694e0d00e3c680","561c925fac06982100493d19","56606f35bb77350d0073249b","567090d51dabd80d00b122ca","56abc1004e8ba20d006a23c9"],"version":"5429beef1163360800ed31fd","__v":10,"project":"5429beef1163360800ed31fa","sync":{"url":"","isSync":false},"reference":false,"createdAt":"2015-09-22T21:03:40.067Z","from_sync":false,"order":7,"slug":"demand-manager","title":"Demand Manager"},"user":"5c529f3fc885e500385e4f02","__v":0,"updates":[],"next":{"pages":[],"description":""},"createdAt":"2019-04-09T05:19:30.460Z","link_external":false,"link_url":"","sync_unique":"","hidden":false,"api":{"settings":"","results":{"codes":[]},"auth":"required","params":[],"url":""},"isReference":false,"order":999,"body":"[block:api-header]\n{\n  \"title\": \"1. Add prebid mobile to app\"\n}\n[/block]\nYou can get Prebid mobile sdk from [here](https://github.com/picatcha/adsnative-sdk-android). Import PrebidMobile sdk in the grade file. \n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"2. Create Prebid banner ad unit\"\n}\n[/block]\nStart with setting the Prebid server to polymorph server link provided to you. \nAlso, set the ServerAccountId to your account Id. \n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"PrebidMobile.setPrebidServerHost(Host.POLYMORPH);\\nPrebidMobile.setPrebidServerAccountId(Constants.PBS_ACCOUNT_ID);\\nPrebidMobile.setApplicationContext(getContext());\",\n      \"language\": \"java\"\n    }\n  ]\n}\n[/block]\nCall the PMUnified ad as you would do get a PM ad as shown below without the pmUnifiedAd.load method. \n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"pmUnifiedAd = new PMUnifiedAd(getActivity(), AD_UNIT_ID, AdHelper.AdTypes.AD_TYPE_ALL);\\n        pmUnifiedAd = new PMUnifiedAd(getActivity(), AD_UNIT_ID, AdHelper.AdTypes.AD_TYPE_ALL);\\n        pmUnifiedAd.setBannerSize(AdHelper.AdSize.BANNER_300x250);\\n        final PMAdViewBinder PMAdViewBinder = new PMAdViewBinder.Builder(R.layout.fan_native_layout)\\n                .bindAssetsWithDefaultKeys(getActivity())\\n                .bindAdChoices(R.id.an_ad_choices)\\n                .build();\\n        Map<String, String> dynamicParams= new HashMap<>();\\n        //TODO: Add dynamicParams here.\\n        PMRequestParameters requestParameters = new PMRequestParameters.Builder().dynamicParameters(dynamicParams).build();\\n        adUnit = new BannerAdUnit(AD_UNIT_ID, width, height);\\n        int millis = 0;\\n        adUnit.setAutoRefreshPeriodMillis(millis);\\n        pmUnifiedAd.registerViewBinder(PMAdViewBinder);\\n\\n        pmUnifiedAd.setBannerAdListener(new PMBannerAdListener() {\\n            :::at:::Override\\n            public void onBannerAdLoaded(PMBannerView bannerView) {\\n                PMLog.e(\\\"onBannerAdLoaded\\\");\\n                nativeAdContainer.removeAllViews();\\n                nativeAdContainer.addView(bannerView, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT, Gravity.CENTER));\\n            }\\n\\n            @Override\\n            public void onBannerReceived(PMBannerView bannerView) {\\n                PMLog.e(\\\"onBannerAdLoaded\\\");\\n            }\\n\\n            @Override\\n            public void onBannerAdClicked(PMBannerView bannerView) {\\n                PMLog.e(\\\"onBannerAdClicked\\\");\\n            }\\n\\n            @Override\\n            public void onBannerAdFailed(String message) {\\n                PMLog.e(message);\\n            }\\n\\n        });\\n        pmUnifiedAd.setNativeAdListener(new PMAdListener() {\\n            @Override\\n            public void onAdLoaded(NativeAdUnit nativeAdUnit) {\\n                PMLog.e(\\\"onNativeLoaded\\\");\\n                nativeAdContainer.removeAllViews();\\n                nativeAdContainer.addView(pmUnifiedAd.renderAdView(nativeAdUnit));\\n            }\\n\\n            @Override\\n            public void onAdFailed(String message) {\\n                PMLog.e(\\\"onBannerAdLoaded\\\");\\n            }\\n\\n            @Override\\n            public void onAdImpressionRecorded() {\\n                PMLog.e(\\\"onBannerAdLoaded\\\");\\n            }\\n\\n            @Override\\n            public boolean onAdClicked(NativeAdUnit nativeAdUnit) {\\n                return false;\\n            }\\n        });\\n\",\n      \"language\": \"java\"\n    }\n  ]\n}\n[/block]\nFinally make the Prebid server call.\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"adUnit.fetchDemand(requestParameters, new OnCompleteListener() {\\n            @Override\\n            public void onComplete(ResultCode resultCode) {\\n                PrebidBannerFragment.this.resultCode = resultCode;\\n                pmUnifiedAd.loadAd(requestParameters);\\n                refreshCount++;\\n            }\\n        });\",\n      \"language\": \"java\"\n    }\n  ]\n}\n[/block]","excerpt":"","slug":"developer-setup-android-in-app-header-bidding-into-prebid-server","type":"basic","title":"Developer Setup - Android In-App Header Bidding into Prebid Server"}

Developer Setup - Android In-App Header Bidding into Prebid Server


[block:api-header] { "title": "1. Add prebid mobile to app" } [/block] You can get Prebid mobile sdk from [here](https://github.com/picatcha/adsnative-sdk-android). Import PrebidMobile sdk in the grade file. [block:api-header] { "type": "basic", "title": "2. Create Prebid banner ad unit" } [/block] Start with setting the Prebid server to polymorph server link provided to you. Also, set the ServerAccountId to your account Id. [block:code] { "codes": [ { "code": "PrebidMobile.setPrebidServerHost(Host.POLYMORPH);\nPrebidMobile.setPrebidServerAccountId(Constants.PBS_ACCOUNT_ID);\nPrebidMobile.setApplicationContext(getContext());", "language": "java" } ] } [/block] Call the PMUnified ad as you would do get a PM ad as shown below without the pmUnifiedAd.load method. [block:code] { "codes": [ { "code": "pmUnifiedAd = new PMUnifiedAd(getActivity(), AD_UNIT_ID, AdHelper.AdTypes.AD_TYPE_ALL);\n pmUnifiedAd = new PMUnifiedAd(getActivity(), AD_UNIT_ID, AdHelper.AdTypes.AD_TYPE_ALL);\n pmUnifiedAd.setBannerSize(AdHelper.AdSize.BANNER_300x250);\n final PMAdViewBinder PMAdViewBinder = new PMAdViewBinder.Builder(R.layout.fan_native_layout)\n .bindAssetsWithDefaultKeys(getActivity())\n .bindAdChoices(R.id.an_ad_choices)\n .build();\n Map<String, String> dynamicParams= new HashMap<>();\n //TODO: Add dynamicParams here.\n PMRequestParameters requestParameters = new PMRequestParameters.Builder().dynamicParameters(dynamicParams).build();\n adUnit = new BannerAdUnit(AD_UNIT_ID, width, height);\n int millis = 0;\n adUnit.setAutoRefreshPeriodMillis(millis);\n pmUnifiedAd.registerViewBinder(PMAdViewBinder);\n\n pmUnifiedAd.setBannerAdListener(new PMBannerAdListener() {\n @Override\n public void onBannerAdLoaded(PMBannerView bannerView) {\n PMLog.e(\"onBannerAdLoaded\");\n nativeAdContainer.removeAllViews();\n nativeAdContainer.addView(bannerView, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT, Gravity.CENTER));\n }\n\n @Override\n public void onBannerReceived(PMBannerView bannerView) {\n PMLog.e(\"onBannerAdLoaded\");\n }\n\n @Override\n public void onBannerAdClicked(PMBannerView bannerView) {\n PMLog.e(\"onBannerAdClicked\");\n }\n\n @Override\n public void onBannerAdFailed(String message) {\n PMLog.e(message);\n }\n\n });\n pmUnifiedAd.setNativeAdListener(new PMAdListener() {\n @Override\n public void onAdLoaded(NativeAdUnit nativeAdUnit) {\n PMLog.e(\"onNativeLoaded\");\n nativeAdContainer.removeAllViews();\n nativeAdContainer.addView(pmUnifiedAd.renderAdView(nativeAdUnit));\n }\n\n @Override\n public void onAdFailed(String message) {\n PMLog.e(\"onBannerAdLoaded\");\n }\n\n @Override\n public void onAdImpressionRecorded() {\n PMLog.e(\"onBannerAdLoaded\");\n }\n\n @Override\n public boolean onAdClicked(NativeAdUnit nativeAdUnit) {\n return false;\n }\n });\n", "language": "java" } ] } [/block] Finally make the Prebid server call. [block:code] { "codes": [ { "code": "adUnit.fetchDemand(requestParameters, new OnCompleteListener() {\n @Override\n public void onComplete(ResultCode resultCode) {\n PrebidBannerFragment.this.resultCode = resultCode;\n pmUnifiedAd.loadAd(requestParameters);\n refreshCount++;\n }\n });", "language": "java" } ] } [/block]