The AdUnit
object is an abstract object that cannot be instantiated. Use the BannerAdUnit or InterstitialAdUnit object to create and configure the desired type of ad unit within your app.
AdUnit
properties and methods are inherited by BannerAdUnit
and InterstitialAdUnit
.
Parameters
configId
: String containing the Prebid Server configuration ID.adType
: BANNER
or INTERSITIAL
. This value will be set by the object based on which type of ad unit object you create.Properties
configId
: Prebid Server configuration ID.adType
: BANNER
or INTERSITIAL
.periodMillis
: Integer defining the refresh time in milliseconds. Default = 0, meaning no auto refresh.keywords
: ArrayList containing keys and values.Trigger a call to Prebid Server to retrieve demand for this Prebid Mobile ad unit.
Parameters
adObj
: bid request objectonCompleteListener
: listener objectIf set on a given Prebid Mobile ad unit, the fetchDemand
function will be called every periodMillis
until stopAutoRefresh
is called. Each call to fetchDemand
will invoke the onComplete
function. This refresh only pertains to Prebid Mobile and not to any ad server refresh processes. It is suggested that the adServers refresh be turned off.
Parameters
periodMillis
: Integer defining the refresh time in milliseconds.Starts the auto-refresh behavior for a given Prebid Mobile ad unit.
Halts the auto-refresh behavior for a given Prebid Mobile ad unit. If no auto-refresh behavior has been set, stopAutoRefresh
will be ignored.
Parameters
none
Ad Unit context keywords object is a free form list of comma separated keywords about the app as defined in app.keyword in OpenRTB 2.5.
Parameters
keyword
: a keyword of type string.
void addContextKeyword(String keyword)
Parameters
keyword
: a keyword of type string.
void addContextKeywords(Set<String> keywords)
Parameters
keyword
: a keyword of type string.
void removeContextKeyword(String keyword)
Parameters none
void clearContextKeywords()
First Party Data (FPD) is free form data supplied by the publisher to provide additional targeting of the user or inventory context, used primarily for striking PMP (Private MarketPlace) deals with Advertisers. Data supplied in the data parameters are typically not sent to DSPs whereas information sent in non-data objects (i.e. setYearOfBirth
, setGender
, etc.) will be. Access to FPD can be limited to a supplied set of Prebid bidders via an access control list.
Data is broken up into two different data types:
The below first party inventory context will apply to the specic ad unit the data object is applied to. For global user or inventory context level first party data, refer to first party data section of the Targeting page.
Parameters
key
: string containing the key for the specific data object
value
: String containing the value for the supplied key
void addContextData(String key, String value)
Parameters
key
: string containing the key for the specific data object
value
: String containing the value for the supplied key
void updateContextData(String key, Set<String> value)
Parameters
key
: string containing the key
void removeContextData(String key)
Parameters none
void clearContextData()
Set a single key-value pair.
Parameters
key
: String containing the key.value
: String containing the value.Define multiple values for a single key.
Parameters
key
: String containing the key.values
: String array containing the list of values for the key.Remove a key and all its associated values from a given Prebid Mobile ad unit.
Parameters
key
: String containing the key you want to remove.Clear all key-value combinations from the Prebid Mobile ad unit.
Parameters
none
InterstitialAdUnit interstitialAdUnit = new InterstitialAdUnit("PREBID_SERVER_CONFIGURATION_ID");
interstitialAdUnit.setUserKeyword("my_key", "my_value"); //will be deprecated in future releases
interstitialAdUnit.addContextKeyword("adunitContextKeywordValue1");
interstitialAdUnit.addContextKeyword("adunitContextKeywordValue2");
interstitialAdUnit.addContextData("adunitContextDataKey1", "adunitContextDataValue1");
interstitialAdUnit.fetchDemand(publisherAdRequest, new onCompleteListener() {
@Override
public void onComplete(ResultCode resultCode) {
dfpInterstitial.loadAd(publisherAdRequest);
}
});