Skip to content

Commit 3a5c9af

Browse files
Prebid SDK - multiformat ad unit for original api (prebid#4889)
* mobile: add info about multiformat ad unit and the BidInfo class * mobile: Android - add info about multiformat ad unit and BidInfo class * mobile: description of NativeParameters * mobile: corrections for the android docs * mobile: fix build errors * mobile: fix build errors * mobile: fix build errors * mobile: fix build errors * mobile: fix build errors * mobile: fix build errors
1 parent 9c09caa commit 3a5c9af

File tree

4 files changed

+812
-310
lines changed

4 files changed

+812
-310
lines changed

prebid-mobile/modules/rendering/android-sdk-integration-pb.md

Lines changed: 43 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ You can use Prebid SDK to monetize your app with a custom ad server or even with
1717

1818
## Transport API
1919

20-
The default ad server for Prebid's Mobile SDK is GAM. The SDK can be expanded to include support for 3rd party ad servers through the fetchDemand function. This function returns the Prebid Server bidder key/values (targeting keys), which can then be passed to the ad server of choice.
20+
The default ad server for Prebid's Mobile SDK is GAM. The SDK can be expanded to include support for 3rd party ad servers through the fetchDemand function. This function returns the Prebid Server bidder key/values (targeting keys), which can then be passed to the ad server of choice.
2121

2222
In this mode, the publisher will be responsible for the following actions:
2323

@@ -39,46 +39,43 @@ This approach is avaliable for the following ad formats:
3939
The basic integration steps for these ad units you can find at the page for integration using [Original API](/prebid-mobile/pbm-api/android/android-sdk-integration-gam-original-api.html). The diference is that you should use the `fetchDemand` function with following signature:
4040

4141
```kotlin
42-
public void fetchDemand(@NonNull Object adObj,
43-
@NonNull OnCompleteListener2 listener) { ... }
44-
45-
public interface OnCompleteListener2 {
46-
/**
47-
* This method will be called when PrebidMobile finishes attaching keywords to unmodifiableMap.
48-
* @param resultCode see {@link ResultCode} class definition for details
49-
* @param unmodifiableMap a map of targeting Key/Value pairs
50-
*/
51-
@MainThread
52-
void onComplete(ResultCode resultCode,
53-
@Nullable Map<String, String> unmodifiableMap);
54-
}
42+
public void fetchDemand(OnFetchDemandResult listener) { ... }
43+
44+
public interface OnFetchDemandResult {
45+
void onComplete(@NonNull BidInfo bidInfo);
46+
}
5547
```
5648

5749
Examples:
5850

59-
```kotlin
60-
private fun loadRewardedVideo() {
61-
adUnit?.fetchDemand { resultCode, unmodifiableMap ->
62-
val keywords: Map<String, String> = HashMap(unmodifiableMap)
51+
``` kotlin
52+
adUnit?.fetchDemand { result ->
53+
if(result.getResultCode() == ResultCode.SUCCESS) {
54+
val keywords = resultCode.targetingKeywords
6355

64-
adServerObject.loadRewardedVideo(ADUNITID_REWARDED, keywords)
56+
makeAdRequest(keywords)
6557
}
6658
}
6759
```
6860

61+
The `BidInfo` provides the following properties:
62+
63+
* `resultCode` - the object of type `ResultCode` describing the status of the bid request.
64+
* `targetingKeywords` - the targeting keywords of the winning bid
65+
* `exp` - the number of seconds that may elapse between the auction and the actual impression. In this case, it indicates the approximate TTL of the bid in the Prebid Cache. Note that the actual expiration time of the bid will be less than this number due to the network and operational overhead. The Prebid SDK doesn't make any adjustments to this value.
66+
* `nativeAdCacheId` - the local cache ID of the winning bid. Applied only to the `native` ad format.
67+
6968
## Rendering API
7069

71-
The integration and usage of the Rendering API is similar to any other Ad SDK. It sends the bid requests to the Prebid Server and renders the winning bid.
70+
The integration and usage of the Rendering API is similar to any other Ad SDK. It sends the bid requests to the Prebid Server and renders the winning bid.
7271

7372
![Rendering with GAM as the Primary Ad Server](/assets/images/prebid-mobile/modules/rendering/Prebid-In-App-Bidding-Overview-Pure-Prebid.png)
7473

75-
7674
### Banner API
7775

7876
Integration example:
7977

80-
81-
```kotlin
78+
``` kotlin
8279
// 1. Create an Ad View
8380
bannerView = BannerView(requireContext(), configId, adSize)
8481
bannerView?.setBannerListener(this)
@@ -90,8 +87,8 @@ viewContainer?.addView(bannerView)
9087
bannerView?.loadAd()
9188
```
9289

93-
{% capture warning_note %}
94-
Pay attention that the `loadAd()` should be called on the main thread.
90+
{% capture warning_note %}
91+
Pay attention that the `loadAd()` should be called on the main thread.
9592
{% endcapture %}
9693
{% include /alerts/alert_warning.html content=warning_note %}
9794

@@ -100,31 +97,31 @@ Pay attention that the `loadAd()` should be called on the main thread.
10097

10198
Initialize the `BannerAdView` with properties:
10299

103-
- `configId` - an ID of a [Stored Impression](/prebid-server/features/pbs-storedreqs.html) on the Prebid server
104-
- `size` - the size of the ad unit which will be used in the bid request.
100+
* `configId` - an ID of a [Stored Impression](/prebid-server/features/pbs-storedreqs.html) on the Prebid server
101+
* `size` - the size of the ad unit which will be used in the bid request.
105102

106103
#### Step 2: Load the Ad
107104
{:.no_toc}
108105

109106
Call `loadAd()` and SDK will:
110107

111-
- make bid request to Prebid
112-
- render the winning bid on display
108+
* make bid request to Prebid
109+
* render the winning bid on display
113110

114111
#### Outstream Video
115112
{:.no_toc}
116113

117114
For **Banner Video** you will also need to specify the `bannerView.videoPlacementType`:
118115

119-
```kotlin
116+
``` kotlin
120117
bannerView.videoPlacementType = PlacementType.IN_BANNER // or any other available type
121118
```
122119

123120
### Interstitial API
124121

125122
Integration example:
126123

127-
```kotlin
124+
``` kotlin
128125
// 1. Create an Interstitial Ad Unit
129126
interstitialAdUnit = InterstitialAdUnit(requireContext(), configId, minSizePercentage)
130127
interstitialAdUnit?.setInterstitialAdUnitListener(this)
@@ -137,27 +134,27 @@ interstitialAdUnit?.loadAd()
137134
interstitialAdUnit?.show()
138135
```
139136

140-
{% capture warning_note %}
141-
Pay attention that the `loadAd()` should be called on the main thread.
137+
{% capture warning_note %}
138+
Pay attention that the `loadAd()` should be called on the main thread.
142139
{% endcapture %}
143140
{% include /alerts/alert_warning.html content=warning_note %}
144141

145142
The **default** ad format for interstitial is **DISPLAY**. In order to make a `multiformat bid request`, set the respective values into the `adUnitFormats` parameter.
146143

147-
```
144+
``` kotlin
148145
interstitialAdUnit = InterstitialAdUnit(
149-
requireContext(),
150-
configId,
146+
requireContext(),
147+
configId,
151148
EnumSet.of(AdUnitFormat.BANNER, AdUnitFormat.VIDEO))
152149
```
153150

154151
#### Step 1: Create an Ad Unit
155152
{:.no_toc}
156153

157-
Initialize the `InterstitialAdUnit ` with properties:
154+
Initialize the `InterstitialAdUnit` with properties:
158155

159-
- `configId` - an ID of a [Stored Impression](/prebid-server/features/pbs-storedreqs.html) on the Prebid server
160-
- `minSizePercentage` - specifies the minimum width and height percent an ad may occupy of a device’s real estate.
156+
* `configId` - an ID of a [Stored Impression](/prebid-server/features/pbs-storedreqs.html) on the Prebid server
157+
* `minSizePercentage` - specifies the minimum width and height percent an ad may occupy of a device’s real estate.
161158

162159
You can also assign the listener for processing ad events.
163160

@@ -173,7 +170,7 @@ Call the `loadAd()` to make a bid request.
173170

174171
Wait until the ad is loaded and present it to the user in any suitable time.
175172

176-
```kotlin
173+
``` kotlin
177174
override fun onAdLoaded(interstitialAdUnit: InterstitialAdUnit) {
178175
//Ad is ready for display
179176
}
@@ -183,11 +180,11 @@ override fun onAdLoaded(interstitialAdUnit: InterstitialAdUnit) {
183180

184181
Integration example:
185182

186-
```kotlin
183+
``` kotlin
187184
// 1. Create an Ad Unit
188185
rewardedAdUnit = RewardedAdUnit(requireContext(), configId)
189186
rewardedAdUnit?.setRewardedAdUnitListener(this)
190-
187+
191188
// 2. Execute the loadAd function
192189
rewardedAdUnit?.loadAd()
193190

@@ -197,8 +194,8 @@ rewardedAdUnit?.loadAd()
197194
rewardedAdUnit?.show()
198195
```
199196

200-
{% capture warning_note %}
201-
Pay attention that the `loadAd()` should be called on the main thread.
197+
{% capture warning_note %}
198+
Pay attention that the `loadAd()` should be called on the main thread.
202199
{% endcapture %}
203200
{% include /alerts/alert_warning.html content=warning_note %}
204201

@@ -207,7 +204,7 @@ Pay attention that the `loadAd()` should be called on the main thread.
207204

208205
Create the `RewardedAdUnit` object with parameters:
209206

210-
- `adUnitId` - an ID of Stored Impression on the Prebid server.
207+
* `adUnitId` - an ID of Stored Impression on the Prebid server.
211208

212209
#### Step 2: Load the Ad
213210
{:.no_toc}
@@ -219,7 +216,7 @@ Call the `loadAd()` to make a bid request.
219216

220217
Wait until the ad is loaded and present it to the user in any suitable time.
221218

222-
```kotlin
219+
``` kotlin
223220
override fun onAdLoaded(rewardedAdUnit: RewardedAdUnit) {
224221
//Ad is ready for display
225222
}

0 commit comments

Comments
 (0)