Skip to main content

Native

Native ad is a flexible type of advertising. You can adapt the display to your UI by preparing a template.

info

Appodeal provides 4 options to implement the layout of native ads 3 templates + your custom implementation All of them are inherited from the same NativeAdView class.

NativeAdView consists of the following components:

  1. NativeIconView - Icon of the native ad.
  2. AdAttributionView - Advertising Indicator. This is a TextView labeled "Ad".
  3. TitleVIew - Title of the native ad.
  4. DescriptionView - Text descriptionView of the native ad.
  5. RatingBarView - Rating of the app in [0-5] range.
  6. NativeMediaView - Media content of the native ad.
  7. CallToActionView - Button for click.
  8. AdChoiceView - Special ad icon provided by ad network.

Templates implementation:

To display them, all you need to do is:

  1. Create programmatically or in your layout file one of View template classes

Native template views classes:

  • NativeAdViewNewsFeed
  • NativeAdViewAppWall
  • NativeAdViewContentStream

NativeAdView for custom implementation:

To display it, all you need to do is:

  1. Create a NativeAdVIew class programmatically or in your layout file
  2. Inside the created NativeAdView, arrange all the View/IconView/MediaView you need for displaying it in any style you prefer
  3. Bind programmatically or in your layout file all necessary View/IconView/MediaView.

Native view for a Custom Implementation:

  • NativeAdView

Integration guide

  1. Create programmatically or in your layout file one of View template classes:
<com.appodeal.ads.nativead.NativeAdViewNewsFeed
android:id="@+id/native_news_feed"
android:layout_width="match_parent"
android:layout_height="wrap_content" />

<com.appodeal.ads.nativead.NativeAdViewAppWall
android:id="@+id/native_app_wall"
android:layout_width="match_parent"
android:layout_height="wrap_content" />

<com.appodeal.ads.nativead.NativeAdViewContentStream
android:id="@+id/native_content_stream"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
  1. Get a view instance from layout OR add a programmatically created ViewTemplate to your View hierarchy:
val newsFeedView = findViewById<NativeAdViewNewsFeed>(R.id.native_news_feed);
val appWallView = findViewById<NativeAdViewAppWall>(R.id.native_app_wall);
val contentStreamView = findViewById<NativeAdViewContentStream>(R.id.native_content_stream);

rootView.addView(newsFeedView)
rootView.addView(appWallView)
rootView.addView(contentStreamView)
  1. When the NativeAd is loaded just register it
if (Appodeal.isLoaded(Appodeal.NATIVE)) {
newsFeedView.registerView(Appodeal.getNativeAdCount(1))
}
  1. When the display has been terminated and you no longer plan to use the NativeAdView, you should call the destroy method:
nativeAdView.destroy()

Check If Ad Is Loaded

To check if at least 1 instance of NativeAd is loaded, use the method:

Appodeal.isLoaded(Appodeal.NATIVE)

To get how many NativeAd instances are loaded, use the method:

val nativeAmount = Appodeal.getAvailableNativeAdsCount()
note

By default, the Appodeal SDK with AutoCahce enabled loads 2 instances of NativeAd each

tip

We recommend you always check whether an ad is available before trying to show it.

Get Loaded Native Ads

To get loaded native ads, use the following method:

val nativeAds: List<NativeAd> = Appodeal.getNativeAds(amount)
danger

Once you get the ads, they are removed from our SDK cache.

Display

To display NativeAd, you need to call the following code:

NativeAdView.registerView(nativeAd: NativeAd)
danger

SDK can't show ads without a network connection!

NativeAdView.registerView() returns a boolean value indicating whether the show method call was passed to the appropriate SDK.

info

Before the registerView(nativeAd) method is called, NativeAdView is in the visibility == GONE state. After the call, the state will automatically change to visibility == VISIBLE.

You don't need to change the visibility state, Appodeal SDK does it automatically.

After calling destroy(), the state will automatically change to visibility == GONE.

tip

NativeAdView and its successors have a built-in attribute tools:visibility="visible" so the view will be displayed in your IDE markup during development.

Placements

Appodeal SDK allows you to tag each impression with different placement. To use placements, you need to create placements in Appodeal Dashboard. Read more about placements.

To show an ad with placement, you have to call show method:

NativeAdView.registerView(nativeAd: NativeAd, yourPlacementName: String)
info

If the loaded ad can’t be shown for a specific placement, nothing will be shown.

If auto caching is enabled, sdk will start to cache another ad, which can affect display rate. To save the loaded ad for future use (for instance, for another placement) check if the ad can be shown before calling the show method:

if (NativeAd.canShow(context: Context, yourPlacementName: String)) {
NativeAdView.registerView(nativeAd: NativeAd, yourPlacementName: String)
}

You can configure your impression logic for each placement.

info

If you have no placements, or call NativeAdView.registerView with a placement that does not exist, the impression will be tagged with 'default' placement and its settings will be applied.

note

Placement settings affect ONLY ad presentation, not loading or caching.

UnregisterView

To unregister the view from displaying the currently registered native ad use the method:

NativeAdView.unregisterView()
note

UnregisterView method does not hide the NativeAdView. It suspends the NativeAd display tracking.

tip

UnregisterView makes sense to use, for example, if the NativeAdView is out of the screen while scrolling in the list, or is temporarily overlapped by another View/Fragment/Activity

Destroy

To destroy the native ad view and perform any necessary cleanup, and hide NativeAdView use the method:

NativeAdView.destroy()
info

This method should be called when the native ad is no longer needed.

Also, when destroy() is called, the unregisterView logic is triggered.

Common Mistakes

  • No adAttributionView

The majority of ad networks require publishers to add a special mark to a native ad, so users don’t mistake them for content. That’s why you always need to make sure, that native ads in your app have the ad attribution (e.g., “Ad”) or the AdChoices icon.

  • Absence of the required native ad elements

Every native ad should contain:

  • titleView TextView;

  • callToActionView Button;

  • adAttribution TextView;

  • NativeIconView or NativeMedaiaView.

  • Native ad elements alteration

Advertisers expect that their ads will be displayed clearly and without any alteration. You can scale buttons and images, but you shouldn't crop, cover or distort them.

  • Overlaying elements of native ads on each other

Make sure, that all elements of a native ad are visible and not overlaid.

Native ads requirements:

  • All of the fields of native ad marked as mandatory must be displayed.
  • Image assets can be resized to fit your ad space but should not be significantly distorted or cropped.

Check Viewability

You can always check in logs if show was tracked and your ad is visible.

You will see the Native [Notify Shown] log if show was tracked successfully.

Appodeal  com.example.app  D Native [Notify Shown]

You can use our demo app as a reference project.

Demo App


If you want to use advanced Native integration, you can find detailed documentation here