VMAX
 
 
 
 
Show Sidebar

Requesting Native Ads – Android SDK without Helper Libraries

Maaf, entri ini hanya tersedia dalam bahasa English. For the sake of viewer convenience, the content is shown below in the alternative language. You may click the link to switch the active language.

It is recommended to use the VMAX Helper Library.

Alternatively, you can use getter functions to render a Native Ad. Once the native ad is cached, the native images are downloaded and as ImageView once the success callbacks is received on adViewDidCacheAd().

To Fetch Native Ad always only use cacheAd(). No need to call showAd() or loadAd() for invoking Native Ads. Once you call the cacheAd() API for native ad you will get callback of native ad in adViewDidCacheAd().

Use the sample below for rendering native ads in your own layout.

Note: For AdMob AdChoice View icon, pass second parameter in above function that is Ad container Layout and keep top right space empty say 15px. VMAX SDK will handle to render AdMob Adchoice icon for AdMob. For Facebook follow below table.

Parameter Recommended Description
nativeAd.getTitle();  Yes  the title property of the ad
nativeAd.getDesc();  Yes  the description property of the ad
nativeAd.getCtaText();  Yes  the call to action title property of the ad
nativeAd.getRating();  Optional
nativeAd.getMediaView();  Yes to be used only for Facebook and Vserv Ads
nativeAd.getNativeAdPartner();  Yes to get Ad partner
nativeAd.getAdChoiceUrl();  Yes to be used only for Facebook
nativeAd.getObjective();  Optional
nativeAd.getVastVideoTag();  Optional
nativeAd.getDesc2();  Optional
nativeAd.getPrice();  Optional
nativeAd.getDownloads();  Optional
nativeAd.getAdChoiceView();  Yes  getAdChoiceView() used only for Facebook. While using this Adchoice view of Facebook than ignore getAdChoiceUrl().It automatically handles click on it.
nativeAd.getAdChoiceView();
nativeAd.getNativeAdType();  Optional
nativeAd.getSalePrice();  Optional
nativeAd.getSponsored();  Optional
nativeAd.getLikes();  Optional
nativeAd.getPhone();  Optional
nativeAd.getAddress();  Optional
nativeAd.getDisplayurl();  Optional
nativeAd.getIcon().getUrl();  Yes
nativeAd.getIcon().getImageView();
nativeAd.getIcon().getWidth();
nativeAd.getIcon().getHeight();
nativeAd.getImageMain().getImageView();  Yes(Any One image)  Check If MainImage available use it. If not follow below images(Priority check should be ImageMain,ImageMedium,ImageTile and ImageBanner )
nativeAd.getImageMain().getUrl();
nativeAd.getImageMain().getWidth();
nativeAd.getImageMain().getHeight();
nativeAd.getImageMedium().getImageView();
 Yes(Any One image)
nativeAd.getImageMedium().getUrl();
nativeAd.getImageMedium().getWidth();
nativeAd.getImageMedium().getHeight();
nativeAd.getImageTile().getImageView();
 Yes(Any One image)
nativeAd.getImageTile().getUrl();
nativeAd.getImageTile().getWidth();
nativeAd.getImageTile().getHeight();
nativeAd.getImageBanner().getImageView();
 Yes(Any One image)
nativeAd.getImageBanner().getUrl();
nativeAd.getImageBanner().getWidth();
nativeAd.getImageBanner().getHeight();
nativeAd.getImageAdChoice().getImageView();
 Yes(Any One image)
 To be used only for Facebook. Make use of getAdChoiceUrl() so as to set click on ImageView.
nativeAd.getImageAdChoice().getUrl();
nativeAd.getImageAdChoice().getWidth();
nativeAd.getImageAdChoice().getHeight();

Additional notes for InMobi Native Ads

From InMobi version 6.0.0 (supported from VMAX Android SDK v3.5.19), InMobi returns a ‘screenshots’ element on their dashboard as shown in the accompanying image.

inmobi_json

  • If you select an image with aspectRatio ‘1.91’, this is mapped to the ‘imageMain’ element of the Native Ad object. Thus, requesting for imageMedium will result in a nil value.
  • If you select an image with aspectRatio ‘1’, this is mapped to the ‘imageMedium’ & ‘imageTile’ elements of the Native Ad object. Thus, requesting for imageMain will result in a nil value.

As a best practice, you should always check if the requested element is nil or not and for non-nil, use the native ad element in rendering your custom native ad layout.

Ad Network Policies

In addition, you need to adhere to the policies shared by AdMob and Facebook here:

If using any ad network other that AdMob or Facebook, be sure to include an Ad symbol so that app users can identify that it’s an ad. The below example shows a test ad from VMAX having an icon, large image, title, CTA button and the ad attribution symbol in the top right.

image00

Once all elements are assigned to Ad parentview and just when your Ad parentView is visible use below function to track impressions and clicks. No need to set any listener on Ad. This function is very important used only when native Ads rendering is without helper libraries.

Parameters:

adView is mandatory for proper handling of Native Ads.
vgroup is mandatory main Ad parnetView.
view is mandatory so as to set listener, it should be CTA view or any other Native Ad element view.
listview is Optional if click on multiple views required. If listview is provided than third argument View view should be parent of the view available in list.

Note: Refer NativeAdConstants class for standard native element name to map to mediation partners like InMobi.

Important Note: Make sure you follow proper Mediation partner Guidelines while working with VMAX Native without helper libraries.

Admob Guidelines: https://support.google.com/admob/answer/6329638?rd=1

Facebook Guidelines: https://developers.facebook.com/docs/audience-network/guidelines/native-ads

Add vmax_custom_native_layout.xml in your Layouts

Add below code in your Activity class

What would you like to do next?