-
Notifications
You must be signed in to change notification settings - Fork 1
Rewarded Video
Rewarded ads will be rendered using the HyBid SDK.
Requirements:
- Ad Zone Id from the PubNative Publisher Dashboard
You can find a demo app with code samples for this type of integration here.
private HyBidRewardedAd mRewarded;
Create an instance of the rewarded ad object using the zone id and setting a listener. Use the load method to make an ad request.
private void loadRewardedVideo() {
mRewarded = new HyBidRewardedAd(this,"ZONE_ID", new HyBidRewardedAd.Listener() {
@Override
public void onRewardedLoaded() {
}
@Override
public void onRewardedLoadFailed(Throwable error) {
}
@Override
public void onRewardedOpened() {
}
@Override
public void onRewardedClosed() {
}
@Override
public void onRewardedClick() {
}
@Override
public void onReward() {
}
});
mRewarded.load();
}
After the ad is successfully retrieved from the server, the onRewardedLoaded callback will notify that the ad is ready to be displayed.
You can display the rewarded video as soon as it's loaded using after getting the callback. Use the show method to display the ad:
mRewarded = new HyBidRewardedAd(this,"ZONE_ID", new HyBidRewardedAd.Listener() {
@Override
public void onRewardedLoaded() {
mRewarded.show();
}
@Override
public void onRewardedLoadFailed(Throwable error) {
}
@Override
public void onRewardedOpened() {
}
@Override
public void onRewardedClosed() {
}
@Override
public void onRewardedClick() {
}
@Override
public void onReward() {
}
});
if you don't want to show the ad right away after being loaded, you can use the isReady method that returns a boolean stating if the ad has been loaded and is ready to be displayed.
if (mRewarded.isReady()) {
mRewarded.show();
}
Finally destroy the rewarded video when the activity or fragment are destroyed
@Override
public void onDestroy() {
if (mRewarded != null) {
mRewarded.destroy();
}
super.onDestroy();
}
Project setup
Displaying ads using HyBid
Displaying Ads with Header Bidding with GAM (DFP)
Mediation
Unity Mediation
Misc