Show Sidebar

Ad Events

 

Ads have events which are exposed to the developer using callbacks, for eg. a rewarded video ad gives a onAdMediaStart callback when the ad media starts, hence this is an indicative for the developer to pause all the media being played in the background etc. To handle in app behavior according to Ad-lifecycle events like optionally you need to set a VmaxAdListener to the VmaxAdView object

onAdReady(VmaxAdView adView)

This callback is received when Ad is ready to render state. For ad formats like banner/billboard/native where SDK is managing refresh cycle this callback will be fired only till ad-space is filled with ad for the first time. For subsequent refresh onAdRefresh() callback will be called.

You are expected to call showAd() API after this event. In-case showAd() API is being called outside this event then you are expected to check AdState as below.

onAdError(VmaxAdError error)
This callback is received when the SDK fails to fetch/render an ad. Use the below mentioned APIs on the VmaxAdError object to obtain more information about the error.


Below are the possible values for the error code.


1001 – ERROR_NOFILL
1002 – ERROR_ADREQUEST_NOT_ALLOWED
1003 – ERROR_MANIFEST_ENTRY_MISSING
1004 – ERROR_TIMEOUT
1005 – ERROR_INTERNAL_SERVER
1006 – ERROR_SDK_INITIALIZATION
1007 – ERROR_MISMATCHUX_OR_MARKUP
1008 – ERROR_NETWORK_ERROR
1009 – ERROR_MANDATORY_PARAM_MISSING
1010 – ERROR_RENDITION_ERROR
1011 – ERROR_PARSING
1012 – ERROR_UNKNOWN
1013 – ERROR_INVALID_REQUEST_ARGUMENTS
1014 – ERROR_AD_EXPIRED

onAdClose(VmaxAdView vmaxAdView)
This callback is received when ad is closed for full-screen ads. You are expected to resume your application animation loops/in-game sounds etc. It is recommended to cache next ad after this event.

onAdView(int visiblity)
This callback is received when ad enters or exits the viewport i.e ad is visible to the user or not. You can check whether ad is in viewport with the below mentioned code.

onAdClick()
This callback is received when the ad is clicked. This will cause your app to go in pause state.

onAdRefresh()
This callback is applicable only for ad formats banner/billboard/native where SDK is managing refresh cycle. It will be triggered for every subsequent ad rotated inside ad-space.

onAdSkippable()
It will be triggered after a particular interval after which the next ad request can be made.

Note: Below callback is applicable only for the ads that has associated media(audio/video)

onAdMediaStart()
It will be triggered when media starts playing.

onAdMediaEnd(boolean isCompleted, long reward)
It will be triggered when media ends playing.
boolean isCompleted: Indicator if the media is completed or not.
long reward: Applicable only for Rewarded videos. It will expose reward amount to be gratified to the user on completing the media(can be checked using isCompleted flag).

onAdRender()
This callback will be triggered when the ad is filled in the ad-space for the first time.

onAdMediaExpand()
It will be triggered when media on a native ad or a billboard ad is expanded to full-screen view.

onAdMediaCollapse()
It will be triggered when media on a native ad or a billboard ad is brought back to normal view from full-screen view.