Overview
Native ads are ad formats that naturally integrate with your app’s UI. You can freely customize ad elements (title, image, description, etc.) to match your app design.Key Features
- Custom design that perfectly integrates with app UI
- Individual access and placement of ad elements
- Option to display advertiser profile information
- Support for additional custom fields
Implementation Steps
Native ad implementation proceeds in the following steps:- Load ad
- Create custom view
- Bind view
- Handle delegates
1. Load Ad
Create anAdropNativeAd instance and load the ad.
Set Context ID
You can set a Context ID for contextual targeting.Use test unit IDs during development. See the Test Unit IDs section.
2. Create Custom View
Compose your native ad view using Storyboard or code.UIKit (Storyboard/XIB)
CreateAdropNativeAdView in Storyboard and connect ad elements as IBOutlets.
UIKit (Code)
3. Bind View
Bind ad elements toAdropNativeAdView to display ad data.
Binding Methods
| Method | Description | Required |
|---|---|---|
setIconView(_:onClick:) | Set icon image view. onClick: ((AdropNativeAd?, UIView) -> Void)? = nil | Optional |
setHeadLineView(_:onClick:) | Set title label. onClick: ((AdropNativeAd?, UIView) -> Void)? = nil | Optional |
setBodyView(_:) | Set description label | Optional |
setMediaView(_:) | Set main image/video view | Optional |
setCallToActionView(_:onClick:) | Set CTA button. onClick: ((AdropNativeAd?, UIView) -> Void)? = nil | Optional |
setAdvertiserView(_:onClick:) | Set advertiser view. onClick: ((AdropNativeAd?, UIView) -> Void)? = nil | Optional |
setProfileLogoView(_:onClick:) | Set advertiser logo image view. onClick: ((AdropNativeAd?, UIView) -> Void)? = nil | Optional |
setProfileNameView(_:onClick:) | Set advertiser name label. onClick: ((AdropNativeAd?, UIView) -> Void)? = nil | Optional |
setNativeAd(_:) | Set ad data | Required |
The
onClick closure is called when the user taps the bound view. It receives the current AdropNativeAd? instance and the tapped UIView as parameters. If not provided, the default click behavior (opening the destination URL) is used.To display advertiser profile, you must enable Show Advertiser Profile for the ad unit in Ad Control Console.
4. Handle Delegates
ImplementAdropNativeAdDelegate to handle ad events.
Delegate Methods
| Method | Required | Description |
|---|---|---|
onAdReceived(_:) | Required | Called when ad loads successfully |
onAdFailedToReceive(_:_:) | Required | Called when ad fails to load |
onAdClicked(_:) | Optional | Called when user clicks the ad |
onAdImpression(_:) | Optional | Called when ad is displayed |
Closure Callbacks
As an alternative to delegates, you can use closure-based callbacks.If both a delegate and closures are set, both will be called.
Ad Properties
You can access ad data through theAdropNativeAd object.
Basic Properties
Advertiser Profile
Custom Fields
You can access additional text items set in Ad Control Console.The
extra field uses additional text item IDs defined in the ad unit settings in Ad Control Console as keys.Property List
| Property | Type | Description |
|---|---|---|
unitId | String | Ad unit ID |
contextId | String | Context ID for contextual targeting |
headline | String | Ad title |
body | String | Ad description |
callToAction | String | CTA button text |
icon | String | Icon image URL |
cover | String | Cover image URL |
asset | String | Main image/video URL |
creative | String | Creative HTML content |
creativeSize | CGSize | Creative content size |
advertiser | String | Advertiser name |
advertiserURL | String | Advertiser URL |
profile | AdropNativeAdProfile | Advertiser profile information |
extra | [String: String] | Additional custom fields |
accountTag | [String: Any] | Account-level tag data |
creativeTag | [String: Any] | Creative-level tag data |
destinationURL | String? | Ad destination URL |
txId | String | Transaction ID |
campaignId | String | Campaign ID |
creativeId | String | Creative ID |
browserTarget | BrowserTarget? | How to open URLs on ad click |
isLoaded | Bool | Whether ad is loaded |
isBackfilled | Bool | Whether ad is a backfill ad |
AdropNativeAdProfile
| Property | Type | Description |
|---|---|---|
displayLogo | String | Advertiser logo image URL |
displayName | String | Advertiser display name |
link | String? | Link to the advertiser’s page |
Custom Click
You can use Custom Click to handle ad click behavior yourself instead of using the default behavior (opening the destination URL).Setup
Entire Click Area
UsesetIsEntireClick(_:) to make the entire AdropNativeAdView clickable.
When
useCustomClick is true, setIsEntireClick(true) is automatically called in setNativeAd(_:).Manual Click
UseperformClick() to manually trigger a click event.
Open URL
Useopen(_:useInAppBrowser:) to open a URL programmatically.
Best Practices
Error Handling
Display fallback UI when ad fails to load to maintain user experience.Test Unit IDs
Use the following test unit IDs during development and testing.| Ad Type | Test Unit ID |
|---|---|
| Native (Image) | PUBLIC_TEST_UNIT_ID_NATIVE |
| Native Video (16:9) | PUBLIC_TEST_UNIT_ID_NATIVE_VIDEO_16_9 |
| Native Video (9:16) | PUBLIC_TEST_UNIT_ID_NATIVE_VIDEO_9_16 |
Backfill Ads
When backfill ads are enabled, backfill ads are automatically loaded when direct ads are unavailable. Use theisBackfilled property to check if the ad is a backfill ad.
To use backfill ads, add the
AdropAds-Backfill dependency. See Getting Started.Related Documentation
Getting Started
SDK installation and initialization
Banner Ads
Implementing banner ads
Interstitial Ads
Implementing interstitial ads
Rewarded Ads
Implementing rewarded ads