@MainThread public class POBBannerView extends FrameLayout implements POBBidEvent
It renders a banner ad from either the ad server SDK or open wrap partner whichever gets a chance in the auction.
Modifier and Type | Class and Description |
---|---|
protected static class |
POBBannerView.POBAdState
Banner ad states
|
static class |
POBBannerView.POBBannerViewListener
Static member class for interaction with the POBBannerView.
|
POBBidEvent.BidEventError
Constructor and Description |
---|
POBBannerView(Context context)
Used to create instances when placed in XML layouts.
|
POBBannerView(Context context,
AttributeSet attrs)
Used to create instances when placed in XML layouts.
|
POBBannerView(Context context,
AttributeSet attrs,
int defStyle)
Used to create instances when placed in XML layouts with default style.
|
POBBannerView(Context context,
java.lang.String publisherId,
int profileId,
java.lang.String adUnitId,
POBAdSize... adSizes)
Constructor
Initializes and returns a newly allocated banner view object for supporting 'No Ad Server Configuration'
Publisher should create object of POBBannerView using this constructor when instantiating
from code.
|
POBBannerView(Context context,
java.lang.String publisherId,
int profileId,
java.lang.String adUnitId,
com.pubmatic.sdk.openwrap.banner.POBBannerEvent event)
Constructor
Initializes and returns a newly allocated banner view object
Publisher should create object of POBBannerView using this constructor when instantiating
from java code.
|
Modifier and Type | Method and Description |
---|---|
void |
destroy()
Invoke this method when your activity/fragment is about to destroy.
|
boolean |
forceRefresh()
Cancels existing ad requests and initiates new ad request.
|
POBRequest |
getAdRequest()
Returns an Object representing OpenWrap ad request.
|
POBBid |
getBid()
Get bid
|
POBAdSize |
getCreativeSize()
Returns the Size of the rendered ad creative
|
POBImpression |
getImpression()
Returns an instance of impression object created internally.
|
void |
init(java.lang.String publisherId,
int profileId,
java.lang.String adUnitId,
POBAdSize... adSizes)
Initializes newly allocated banner view object for supporting 'No Ad Server Configuration'
Invoke this method only if POBBannerView is inflated via xml resource.
|
void |
init(java.lang.String publisherId,
int profileId,
java.lang.String adUnitId,
com.pubmatic.sdk.openwrap.banner.POBBannerEvent event)
Initializes newly allocated banner view object.
|
void |
loadAd()
Initiate the loading of a banner ad, if the
POBRequest is available then it proceeds with further
execution else it will log error |
void |
loadAd(java.lang.String bidResponse)
Initiates the loading of a banner ad with oRTB bid response.
|
void |
pauseAutoRefresh()
Pauses the auto refresh, By default, banner refreshes automatically as per
configured refresh interval on OpenWrap portal.
|
void |
proceedOnError(POBBidEvent.BidEventError error,
java.lang.String errorMessage)
Introduced in OpenWrapSDK v3.6.0
|
boolean |
proceedToLoadAd()
Proceeds with bid flow, This method should be called only when
POBBidEventListener is set
Note: Should be called from Main/UI thread. |
void |
resumeAutoRefresh()
Resumes the auto-refresh as per configured refresh interval on OpenWrap portal, call this
method only if you have previously paused auto-refresh using `pauseAutoRefresh()`.
|
void |
setBidEventListener(POBBidEventListener bidEventListener)
Sets the BidEventListener for the ad view
Note: Proper reference management practices should be observed when using this listener
|
void |
setListener(POBBannerView.POBBannerViewListener listener)
Sets instance of POBBannerViewListener for the Banner view.
|
public POBBannerView(@NonNull Context context)
context
- Activity contextpublic POBBannerView(@NonNull Context context, @Nullable AttributeSet attrs)
context
- Activity contextattrs
- ui attributespublic POBBannerView(@NonNull Context context, @Nullable AttributeSet attrs, int defStyle)
context
- Activity contextattrs
- ui attributesdefStyle
- default stylepublic POBBannerView(@NonNull Context context, @NonNull java.lang.String publisherId, int profileId, @NonNull java.lang.String adUnitId, @NonNull POBAdSize... adSizes)
context
- Activity contextpublisherId
- Identifier of the publisherprofileId
- Profile ID of an ad tagadUnitId
- Ad unit id used to identify unique placement on screen.adSizes
- List of banner ad sizes for this impressionpublic POBBannerView(@NonNull Context context, @NonNull java.lang.String publisherId, int profileId, @NonNull java.lang.String adUnitId, @NonNull com.pubmatic.sdk.openwrap.banner.POBBannerEvent event)
context
- Activity contextpublisherId
- Identifier of the publisherprofileId
- Profile ID of an ad tagadUnitId
- Ad unit id used to identify unique placement on screen.event
- Valid instance of class implementing POBBannerEventpublic void init(@NonNull java.lang.String publisherId, int profileId, @NonNull java.lang.String adUnitId, @NonNull com.pubmatic.sdk.openwrap.banner.POBBannerEvent event)
POBRequest
publisherId
- Identifier of the publisherprofileId
- Profile ID of an ad tagadUnitId
- Ad unit id used to identify unique placement on screen.event
- Valid instance of class implementing POBBannerEventpublic void destroy()
public void pauseAutoRefresh()
It is recommended to use this method whenever the ad view is about to be hidden from the user for any period of time, to avoid unnecessary ad requests. You can then call `resumeAutoRefresh()` to resume the refresh when banner becomes visible.
public void resumeAutoRefresh()
public void init(@NonNull java.lang.String publisherId, int profileId, @NonNull java.lang.String adUnitId, @NonNull POBAdSize... adSizes)
publisherId
- Identifier of the publisherprofileId
- Profile ID of an ad tagadUnitId
- Ad unit id used to identify unique placement on screen.adSizes
- List of banner ad sizes for this impression@RequiresPermission(allOf={<error>,<error>}) public void loadAd()
POBRequest
is available then it proceeds with further
execution else it will log error@RequiresPermission(allOf={<error>,<error>}) public void loadAd(@NonNull java.lang.String bidResponse)
bidResponse
- oRTB response of format - oRTB-2.5@RequiresPermission(allOf={<error>,<error>}) public boolean forceRefresh()
It may skip force refresh in below cases: 1). Ad is being loaded 2). Waiting response from ad server SDK (if applicable) 3). User interacting with ad (Opening Internal browser or expanding ad)
@Nullable public POBImpression getImpression()
@Nullable public POBRequest getAdRequest()
public void setListener(@Nullable POBBannerView.POBBannerViewListener listener)
listener
- Instance of POBBannerViewListenerpublic void setBidEventListener(@Nullable POBBidEventListener bidEventListener)
setBidEventListener
in interface POBBidEvent
bidEventListener
- reference of POBBidEventListenerpublic boolean proceedToLoadAd()
POBBidEvent
POBBidEventListener
is set
Note: Should be called from Main/UI thread. Also, unnecessary duplicate call will fail and
appropriate errors will be logged with return value `false`proceedToLoadAd
in interface POBBidEvent
public void proceedOnError(@NonNull POBBidEvent.BidEventError error, @NonNull java.lang.String errorMessage)
POBBidEvent
Proceeds with error, If integration type is of primary ad server case like DFP and MoPub, the execution is continued by invoking ad server call ignoring OpenWrap's bid. In case of No ad server integration, flow is completed by setting its state to default considering error at client side. Note: Should be called from Main/UI thread
proceedOnError
in interface POBBidEvent
error
- the error of type POBBidEvent.BidEventError
Example:
Scenario 1 : When bid is failed in client-side in-app auction loss
proceedOnError(BidEventError#CLIENT_SIDE_AUCTION_LOSS);
Scenario 2 : When bid is expired proceedOnError(BidEventError#BID_EXPIRED);
errorMessage
- custom description for the error
Example:
When the bid is failed in client-side application the publisher
can pass on custom message to identify the issue in logs@Nullable public POBBid getBid()
getBid
in interface POBBidEvent
@Nullable public POBAdSize getCreativeSize()