Skip to main content

Native Ad Units

Create Native Ad Unit#


If you miss to Initialize the SDK, this method will fail to return a response.

To create an native ad, first create an MesonNative object

val nativeAd = MesonNative(this,AD_UNIT_ID, AdSize(width,height))

Set the Listener#

Track the ad lifecycle for native ads. All the available events for native ads are listed below.

override fun onAdLoadSucceeded(nativeAd: MesonNative) {
override fun onAdLoadFailed(nativeAd: MesonNative, status: MesonAdRequestStatus) {
override fun onAdClicked(nativeAd: MesonNative, params: HashMap<String, Any>) {
override fun onAdImpression(nativeAd: MesonNative, impressionData:JSONObject?) {
override fun onAdDisplayed(nativeAd: MesonNative) {
override fun onUserLeftApplication(nativeAd: MesonNative) {

Load Ad#

The publisher can request for a native ad by invoking this method. This will request an ad from all demand sources, select a winner, and make it available on the SDK.


Get Ad View#

The ad is returned to the user when getAdView method is called. It is recommended to call this method in the onAdLoadSucceeded callback method.

//Create NativeAdViewConfiguration object
val adViewConfiguration = MesonNativeAdViewConfiguration.Builder()
//Call getAdView