Native ads are different from standard ad units in that rather than being a single, self-contained entity from the perspective of a publisher, they are a collection of individual components that can be laid out and interacted with individually, so the publisher can control the user experience of each element of the ad along with its layout. Upon retrieving a Native Ad, the SDK returns an object that contains information about the ad along with a list of components that represent the contents of the ad. The three types of components that can returned are:
- VASTextView - This a view that contains text.
- VASDisplayMediaView - This a view that may contain either an image or video.
- NativeComponentBundle - This is an organizational structure which contains a collection of components which may include other Bundles.
Different types of Native Ads may contain different components. In order to know the components that are available in an ad, the Ad Type can be requested using the following method:
At present the only Native Ad Type support by the Verizon Ads SDK is “inline” which has defined set of components and component keys. As Verizon Media continues to innovate in the area of more engaging and high value ads, other ad types will become available. This is an important consideration when designing the integration of Verizon Ads SDK into an application. Below is a table that contains the components available for the “inline” Native Ad Type. The components that are
Advertiser Required must be displayed in order to get credit for ad impressions.
|Component ID||Component Type||Advertiser Required|
There are specific methods for accessing the three component types within the ad based on component type; VASTextView, VASDisplayMediaView, and NativeComponentBundle.
Accessing VASTextView Components
Accessing VASDisplayMediaView Components
Accessing NativeComponentBundle Components
Accessing Components for ‘Inline’ Native Ad
The following are examples of accessing some of the components found in an “inline” Native Ad Type. Please refer to the sample application for an example of implementing a Native Ad within an App.
Integrating Native Ad Placements
To add a native add to an app, import the required headers, instantiate a NativeAdFactory, and load the ad. Once loaded, retrieve the components and add them to the app’s view hierarchy for display.
1. Import the required classes
2. Create a native ad factory
An instance of the native ad factory is required to load an ad. The factory is created once, typically when the app’s view controller or activity is initialized.
Native ad factory callbacks
The NativeAdFactory callbacks communicate events related to ad loading. These are implemented as interfaces on Android and delegates on iOS. Please refer to the API documentation for Android and iOS for a complete list of available callbacks.
3. Load an ad
Prior to displaying an ad, you must load it as seen below.
Native ad callbacks
The Native ad callbacks provide the state of an ad that has been displayed. For example, callbacks signal user actions, errors, etc. Please refer to the API documentation for Android and iOS for a complete list of available callbacks.
4. Retrieve ad components
Once an Ad has been loaded successfully, components can be retrieved for subsequent display. The number, type of components, and structure of these will vary based on the AdType that is returned. At present the only supported AdType is “inline”. As Verizon Media and the industry expands more AdTypes will become available.
5. Display the ad
Once the ad components have been retrieved, styling can be applied and they can be laid out within the app based on any specific requirements. The components that are returned can be laid out and treated the same as their base class. Below is a chart that outlines the Component class and the class from which they were derived.
VASTextView and VASDisplayMedia view can be configured and laid out using procedural or declarative layout methods in the same manner as the classes they are derived from.
6. Android Only - Destroy the ad
When the ad instance is no longer needed or when the activity is finished, the instance must be destroyed to free up resources.
For a complete example of implementing a Native Ad within an app, please review the sample application.