Native Ad Template Assets
Asset | Required | View Type | Description |
AdChoices | Yes | RelativeLayout | An AdChoices icon must be displayed in your ad to enable the user to learn about interest-based advertising.
The SDK will decide when it is needed to display the icon and will also handle the tap event on the view by opening an opt-out page in the browser.
Parameters: The size of the view: 20×20.
You must place the view on any of the four corners of the ad template; upper right hand corner is recommended.
|
Title | Yes – If Icon or MainAsset is not used. | TextView | String representation of the native ad, which could be the name of the product or the service being advertised. Parameters: Maximum title length. The Developer should explicitly set this value while binding the template view to the native ad asset.
It is recommended that the TextView is laid out to display at least 25 characters.
Only native ads with title assets whose length is less than the requested maximum title length will be returned.
|
Icon | Yes – If Title or MainAsset is not used. | ImageView | A squared image that shows the icon of the product, service, brand, … etc. Parameters: Minimum width and height. The Developer should explicitly set these values while binding the template view to the native ad asset.
Recommended minimum width and height of the Icon ImageView is 50×50.
Only native ads with icon assets whose width and height is greater than the requested minimum icon width and height will be returned.
|
MainAsset
|
Yes – If Title or Icon is not used. | RelativeLayout | The Native Ad main asset can be one of the below types:
· Image · XHTML (HTML+JavaScript) · Video
The MainAsset is a RelativeLayout which is used as a container view for the actual native ad main asset. The SDK will automatically create the adequate RelativeLayout type that match the native ad main asset.
Parameters: Minimum width and height. The Developer should explicitly set these values while binding the template view to the native ad asset.
The main asset RelativeLayout width and height aspect ratio should always be W/H=1.91. It is recommended to use 320×167 points.
Only native ads with main assets whose width and height is greater than the requested minimum main asset width and height will be returned.
|
Sponsored | No | TextView | “Sponsored by” message containing the brand name of the sponsor.
Parameters: Maximum sponsored length. The Developer should explicitly set this value while binding the template view to the native ad asset.
It is recommended that the TextView is laid out to display at least 10 characters.
|
Description | No | TextView | Descriptive text associated with the product or the service being advertised.
Parameters: Maximum description length. The Developer should explicitly set this value while binding the template view to the native ad asset.
It is recommended that the TextView is laid out to display at least 100 characters. |
Star Rating | No | RatingBar | Consists of five stars, which represents the rating of an app.
Parameters: Minimum width and height. The Developer should explicitly set these values while binding the template view to the native ad asset.
Recommended minimum width and height for the Star Rating ImageView is to follow aspect ratio of W/H=5 such as 100×20. |
Likes | No | TextView | Number of social ratings or “likes” of the product being offered to the user.
Parameters: Maximum likes length. The Developer should explicitly set this value while binding the template view to the native ad asset.
It is recommended that the TextView is laid out to display at least 20 characters. |
Downloads | No | TextView | Number of downloads of the product being offered to the user.
Parameters: Maximum downloads length. The Developer should explicitly set this value while binding the template view to the native ad asset.
It is recommended that the TextView is laid out to display at least 25 characters.
|
Price | No | TextView | Price for product / app / in-app purchase. Value should include currency symbol in localized format.
Parameters: Maximum price length. The Developer should explicitly set this value while binding the template view to the native ad asset. It is recommended that the TextView is laid out to display at least 20 characters. |
Sale price | No | TextView | Sale price that can be used together with price to indicate a discounted price compared to a regular price. Value should include currency symbol in localized format.
Parameters: Maximum sale price length. The Developer should explicitly set this value while binding the template view to the native ad asset. It is recommended that the TextView is laid out to display at least 15 characters. |
Phone | No | TextView | Formatted string that represents the phone number.
Parameters: Maximum phone length. The Developer should explicitly set this value while binding the template view to the native ad asset. It is recommended that the TextView is laid out to display at least 20 characters. |
Address | No | TextView | Address data.
Parameters: Maximum address length. The Developer should explicitly set this value while binding the template view to the native ad asset. It is recommended that the TextView is laid out to display at least 100 characters. |
Description 2 | No | TextView | Additional descriptive text associated with the product or service being advertised.
Parameters: Maximum Address 2 length. The Developer should explicitly set this value while binding the template view to the native ad asset. It is recommended that the TextView is laid out to display at least 100 characters. |
Display URL | No | TextView | Display URL data.
Parameters: Maximum display URL length. The Developer should explicitly set this value while binding the template view to the native ad asset.
It is recommended that the TextView is laid out to display at least 50 characters.
|
Call to action “CTA” | No | Button | Descriptive text describing a ‘call to action’ button for the destination URL such as open, register, install.
Parameters: Maximum CTA length. The Developer should explicitly set this value while binding the template view to the native ad asset. It is recommended that the label of button is laid out to display at least 20 characters. |
Views | No | TextView | Number of times the ad has been viewed.
Parameters: Maximum Views length. The Developer should explicitly set this value while binding the template view to the native ad asset.
It is recommended that the TextView is laid out to display at least 20 characters. |
ADFNativeAdListener interface
Method | Description |
public void onLoadAd(ADFNativeAd ad) | Fired when the ad is loaded successfully. |
public void onFail(
ADFNativeAd ad, ADFErrorCode errorCode, String message) |
Fired when failed to load an ad with failure message.
Parameters ad: AdFalcon native ad error: type of error message: description for error
|
public void renderExtraData (
View view, Hashtable<Integer, String> hashtable) |
This method is used to allow the app to draw any extra data assets that were not bound explicitly in the ADFAssetsBinder.
This is used if the app is willing to entirely take over the extra data display and presentation. |
public void onPresentAdScreen(
ADFNativeAd ad) |
Ad action has been viewed.
|
public void onDismissAdScreen(
ADFNativeAd ad) |
Ad action has been closed.
|
public void onLeaveApplication() | Ad action has been viewed in another application |
ADFTargetingParams class
Variable | Required | Description | Values |
Language | No | A two-characters string parameter indicating Ad language | ar, en |
Postal code | No | A string parameter containing the user’s postal/ZIP code
|
11121 |
Area code | No | A string parameter containing the user’s area code | 06 |
Age | No | An integer parameter containing the user’s age | 27 |
Keywords | No | List of keywords in comma separated format. AdFalcon’s ads selector engine will search for ads containing these keywords. | ex. sport, news, lifestyle, …etc. |
Gender | No | A parameter containing the user’s gender | NONE
GENDER_MALE GENDER_FEMALE |
Country code | No | County code of the end user in ISO 3166-1 alpha-2 format code (two-letter code)
|
JO, SA …etc. |
Birthdate | No | Birthdate of application user in format dd.MM.yyyy | |
Additional Info | No | A Map of keys and values to add additional parameters. | |
Location: Latitude, Longitude | No | The geolocation information of the device. The location information is divided into two double values; latitude and longitude.
|
35.654, 34.6598 |
ADFNativeAd class
Method | Description |
public void setTesting(boolean test) | Used to inform AdFalcon network if your application is working in test or production mode. |
public void setListener(
ADFNativeAdListener listener) |
Set ADFNativeAdListener. |
public ADFNativeAdListener getListener() | Get ADFNativeAdListener. |
public void setLogging(boolean logging) | Enable/Disable logging while loading native ad. |
public boolean getLogging() | Check if logging is enabled. |
public ADFNativeAdStatus getStatus() | Get status of native ad. such as loading, loaded, shown, clicked and failed. |
public String getErrorMessage() | Get error message when the status is failed |
public void destroy() | This method should be called either in onDestroy() method to finalize the ADFNativeAd or when you are done with the ADFNativeAd object.
After calling this method the SDK will dispose the native ad. |
public void loadAd(
String siteID, ADFTargetingParams params, ADFAssetsBinder binder) |
This method is used to load new ad.
|
ADFAssetsBinder.Builder class
Method | Description |
public void addIconImageView (int resID, int minWidth, int minHeight) | Binds the native ad icon asset to its corresponding ImageView in the template.
Params · resID: resource id of the image view in the layout. · minWidth: minimum width of icon. · minHeight: minimum height of icon. |
public void addTitleTextView (int resID, int maxLen) | Binds the native ad title asset to its corresponding TextView in the template.
Params · resID: resource id of the text view in your created layout. · maxLen: maximum length of title text. |
public void addMainAssetRelativeLayout (int resID, int minWidth, int minHeight) | Binds the native ad main asset to its corresponding RelativeLayout in the template.
The MainAsset is a RelativeLayout which is used as a container view for the actual native ad main asset which can be: Image, or XHTML (HTML+JavaScript), or Video
The SDK will automatically create the adequate View type that match the native ad main asset.
Params · resID: resource id of the RelativeLayout in the template. · minWidth: minimum width of the content of RelativeLayout. · minHeight: minimum height of the content of RelativeLayout. |
public void addDescriptionTextView (int resID, int maxLen) | Binds the native ad description asset to its corresponding TextView in the template.
Params · resID: resource id of the view in your created layout. · maxLen: maximum length of description text. |
public void addStarRatingBar (int resID) | Binds the native ad rating asset to its corresponding RatingBar in the template.
Params · resID: resource id of the view in your created layout. |
public void addActionButton (int resID, int maxLen) | Binds the native ad button asset to its corresponding Button in the template.
Params · resID: resource id of the view in your created layout. · maxLen: maximum length of action text. |
public void addExtraDataTextView (int dataID, int resID, int maxLen) | Binds the native ad data asset to its corresponding TextView in the template.
All extra data views are optional which means native ad can be returned even if they don’t include the requested extra data assets. Additionally, the SDK will hide any extra data view that is not included in the returned native ad.
Params · dataID: data id that you want to show based on enum in ADFAssetsBinder class · resID: resource id of the view in your created layout. · maxLen: maximum length of data content. |
public void addAdChoicesRelativeLayout (int resID) | An AdChoices icon must be displayed in your ad to enable the user to learn about interest-based advertising.
The SDK will decide when it is needed to display the icon and will also handle the tap event on the view by opening an opt-out page in the browser.
Parameters: The size of the view: 20×20.
You must place the view in any one of the four corners of the ad template; upper right hand corner is recommended.
|
public ADFAssetsBinder build() | This method is used to build the native ad. |
ADFAssetsBinder data id enum
ADFAssetsBinder data id enum defines the extra data that you want to add in your native ad.
Enum | Description |
DATA_ID_SPONSORED | “Sponsored By” message containing the brand name of the sponsor. |
DATA_ID_LIKES | Number of social ratings or “likes” of the product being offered to the user. |
DATA_ID_DOWNLOADS | Number of downloads of the product being offered to the user. |
DATA_ID_PRICE | Price for product / app / in-app purchase. Value should include currency symbol in localized format. |
DATA_ID_SALEPRICE | Sale price that can be used together with price to indicate a discounted price compared to a regular price. Value should include currency symbol in localized format. |
DATA_ID_PHONE | Phone number |
DATA_ID_ADDRESS | Additional address text associated with the product or service being advertised |
DATA_ID_DESC2 | Additional descriptive text associated with the product or service being advertised |
DATA_ID_DISPLAYURL | Display URL for the text ad |
DATA_ID_VIEWS | Number of views of this ad |
ADFNativeAdStatus enum
ADFNativeAdStatus enum defines the status of the native ad.
Enum | Description |
Loading | Native ad is loading currently. |
Loaded | Native ad has finished loading. |
Shown | Native ad has been shown. |
Failed | An error occurred while loading or showing the native ad. |
Clicked | User has clicked on the native ad. |
ADFErrorCode enum
ADFErrorCode Enum defines AdFalcon SDK and Ad Server error codes.
Enum | Description |
GENERIC_SDK_ERROR | Error occurred in the SDK. |
INTERNAL_SERVER_ERROR | Error occurred in AdFalcon server. |
COMMUNICATION_ERROR | SDK cannot reach the AdFalcon server; mostly for issues related to the phone internet connection. |
NO_AD_AVAILABLE | No ad is available in the AdFalcon store that meets the ad request parameters. |
INVALID_PARAM | An invalid ad request parameter has been set. |
MISSING_PARAM | A required ad request parameter has not been set. |