Media Native Placement
Media Native renders the same video and display creatives as the Media format, but inside a layout you build and control instead of the SDK's own container. The SDK still owns the paid click, the same as Media.
Sample App
The official Teads SDK sample application includes working examples of this format. Use it for implementation examples and as a reference while you set up this placement.
Example
- Swift
- Objective-C
import UIKit
import TeadsSDK
class NativeAdViewController: UIViewController {
private var nativePlacement: TeadsAdPlacementMediaNative?
private var nativeAdView: TeadsNativeAdView?
override func viewDidLoad() {
super.viewDidLoad()
setupNativeAd()
}
private func setupNativeAd() {
// Create custom native ad view
nativeAdView = createCustomNativeAdView()
// Create configuration
let config = TeadsAdPlacementMediaConfig(
pid: 124859,
articleUrl: URL(string: "https://example.com/article/123")
)
// Create placement
nativePlacement = TeadsAdPlacementMediaNative(config, delegate: self)
// Load and bind the ad
do {
let binder = try nativePlacement?.loadAd()
if let nativeAdView = nativeAdView {
binder?(nativeAdView)
addNativeAdToView(nativeAdView)
}
} catch {
print("Failed to load native ad: \(error)")
}
}
private func createCustomNativeAdView() -> TeadsNativeAdView {
// Create your custom native ad view
// This can be designed in Interface Builder or programmatically
let adView = TeadsNativeAdView(frame: .zero)
// Customize the appearance to match your app
adView.backgroundColor = .systemBackground
adView.layer.cornerRadius = 12
adView.layer.shadowColor = UIColor.black.cgColor
adView.layer.shadowOpacity = 0.1
adView.layer.shadowRadius = 8
return adView
}
private func addNativeAdToView(_ adView: UIView) {
view.addSubview(adView)
adView.translatesAutoresizingMaskIntoConstraints = false
NSLayoutConstraint.activate([
adView.leadingAnchor.constraint(equalTo: view.leadingAnchor, constant: 16),
adView.trailingAnchor.constraint(equalTo: view.trailingAnchor, constant: -16),
adView.centerYAnchor.constraint(equalTo: view.centerYAnchor),
adView.heightAnchor.constraint(equalToConstant: 250)
])
}
}
#import <UIKit/UIKit.h>
#import <TeadsSDK/TeadsSDK-Swift.h>
@interface NativeAdViewController : UIViewController
@property (nonatomic, strong) TeadsAdPlacementMediaNative *nativePlacement;
@property (nonatomic, strong) TeadsNativeAdView *nativeAdView;
@end
@implementation NativeAdViewController
- (void)viewDidLoad {
[super viewDidLoad];
[self setupNativeAd];
}
- (void)setupNativeAd {
// Create custom native ad view
self.nativeAdView = [self createCustomNativeAdView];
// Create the placement directly with the Objective-C-friendly convenience
// initializer (the Config-based Swift initializer does not bridge)
self.nativePlacement = [[TeadsAdPlacementMediaNative alloc]
initWithPid:124859
articleUrl:[NSURL URLWithString:@"https://example.com/article/123"]
delegate:self];
// Load and bind the ad
NSError *error = nil;
void (^binder)(TeadsNativeAdView *) = [self.nativePlacement loadAdAndReturnError:&error];
if (error) {
NSLog(@"Failed to load native ad: %@", error);
return;
}
if (self.nativeAdView) {
if (binder) {
binder(self.nativeAdView);
}
[self addNativeAdToView:self.nativeAdView];
}
}
- (TeadsNativeAdView *)createCustomNativeAdView {
// Create your custom native ad view
// This can be designed in Interface Builder or programmatically
TeadsNativeAdView *adView = [[TeadsNativeAdView alloc] initWithFrame:CGRectZero];
// Customize the appearance to match your app
adView.backgroundColor = [UIColor systemBackgroundColor];
adView.layer.cornerRadius = 12;
adView.layer.shadowColor = [UIColor blackColor].CGColor;
adView.layer.shadowOpacity = 0.1;
adView.layer.shadowRadius = 8;
return adView;
}
- (void)addNativeAdToView:(UIView *)adView {
[self.view addSubview:adView];
adView.translatesAutoresizingMaskIntoConstraints = NO;
[NSLayoutConstraint activateConstraints:@[
[adView.leadingAnchor constraintEqualToAnchor:self.view.leadingAnchor constant:16],
[adView.trailingAnchor constraintEqualToAnchor:self.view.trailingAnchor constant:-16],
[adView.centerYAnchor constraintEqualToAnchor:self.view.centerYAnchor],
[adView.heightAnchor constraintEqualToConstant:250]
]];
}
@end
Ad Lifecycle Listener
Implement TeadsAdPlacementEventsDelegate to observe playback, clicks, and viewability. See Placement Events Listener for the full event reference and error handling guide.
Checklist
- ✅ Ensure Brand Safety is enabled
- ✅ Ensure you comply with privacy legal requirements (GDPR/CCPA/GPP)
- ✅ Comply with app-ads.txt
- ✅ Implement proper error handling
- ✅ Test with the PIDs in Test PIDs and Configurations