Before You Start

Before integrating ads unit in your app, you must:

  • In the AdTiming UI, create an account, create an app, and create an ad placement using the format 'Rewarded Video'. You can follow guides here.
  • Follow our steps to iOS SDK Integration by integrating the AdTiming SDK into your project.
  • If you use mediation, go to Add Mediation Networks and make sure you have added the ad networks' SDKs and the corresponding adapters you wish to work with in your app.

Native Ad

Native ad is a form of paid media where the ad experience follows the natural form and function of the user experience in which it is placed.

Step 1. Initialize Native Ad

The AdTiming SDK fires several events to inform you of Native Ad activity. To display Native Ads, you need to create a brand new AdTimingNative object, set up its delegate and load the ads. The following snippet demonstrates how to use the AdTimingNative class to create Native Ad objects and implement the AdTimingNativeDelegate to receive Native Ad events.

Create AdTimingNativeView and AdTimingNative

Add the following code to create a AdTimingNative object and a AdTimingNativeView object, and add your Delegate to register for the events. The SDK will notify the Delegate of all possible events listed in section below.

Note: Here we use "self" which means the callback function is implemented in the current object.

@property (nonatomic, strong) AdTimingNative *native;
@property (nonatomic, strong) AdTimingNativeAd *nativeAd;
@property (nonatomic, strong) AdTimingNativeView *nativeView;
@property (nonatomic, strong) UIImageView *iconView;
@property (nonatomic, strong) UILabel *titleLabel;
@property (nonatomic, strong) UILabel *bodyLabel;

- (void)viewDidLoad {
    self.native = [[AdTimingNative alloc]initWithPlacementID:@"YOUR_PLACEMENT_ID"];
    self.native.delegate = self;
    [self.view addSubview:self.nativeView];

- (AdTimingNativeView*)nativeView{
        _nativeView = [[AdTimingNativeView alloc]initWithFrame:CGRectMake(0,300, self.view.frame.size.width, 300)];
        _nativeView.mediaView = [[AdTimingNativeMediaView alloc]initWithFrame:CGRectMake(0, 0, self.view.bounds.size.width, 250)];
        [_nativeView addSubview:_nativeView.mediaView];
        _iconView = [[UIImageView alloc]initWithFrame:CGRectMake(self.view.frame.size.width-40, 0, 40, 40)];
        [_nativeView addSubview:_iconView];
        _titleLabel = [[UILabel alloc]initWithFrame:CGRectMake(0, 270, self.view.frame.size.width, 15)];
        _titleLabel.font = [UIFont systemFontOfSize:13];
        [_nativeView addSubview:_titleLabel];
        _bodyLabel = [[UILabel alloc]initWithFrame:CGRectMake(0, 285, self.view.frame.size.width, 15)];
        _bodyLabel.font = [UIFont systemFontOfSize:13];
        [_nativeView addSubview:_bodyLabel];
        _nativeView.hidden = YES;
   return _nativeView;
var nativeAd: AdTimingNativeAd?
private lazy var nativeView: AdTimingNativeView = {
let view = AdTimingNativeView(frame: CGRect(x: 0, y: 300, width: self.view.frame.size.width, height: 300))
view.mediaView = AdTimingNativeMediaView(frame: CGRect(x: 0, y: 0, width: self.view.frame.size.width, height: 300))
return view

private lazy var native: AdTimingNative = {
let native = AdTimingNative(placementID: "YOUR_PLACEMENT_ID")
native.delegate = self
return native


Native Delegate (AdTimingNativeDelegate)

Implement the following callback function in your code to process ad logic when receiving the activity of your ad. For example invoke show function to serve Ad to your users when the Natie Ad is ready. 

The methods declared by the AdTimingNativeDelegate protocol allow the adopting delegate to respond to messages from the AdTimingNative class and thus respond to operations such as whether the native ad has been loaded.

/// Invoked when the ad is available.
/// You can then show the ad.
- (void)adtimingNative:(AdTimingNative*)native didLoad:(AdTimingNativeAd*)nativeAd{
     NSLog(@"NativeAd Did Load");
     self.nativeAd = nativeAd;

/// Invoked when the call to load an ad has failed.
/// Parameter error contains the reason for the failure.
- (void)adtimingNativeDidFailToLoad:(AdTimingNative*)native withError:(NSError*)error{
     NSLog(@"NativeAd Did Fail");

/// Invoked when the Ad begins to show.
- (void)adtimingNativeWillExposure:(AdTimingNative*)native{
     NSLog(@"NativeAd Will Exposure");

/// Invoked when the ad finishes playing.
- (void)adtimingNativeDidClick:(AdTimingNative*)native{
     NSLog(@"NativeAd Did Click");
/// Invoked when the ad is available.
/// You can then show the ad.
func adtimingNative(_ native: AdTimingNative, didLoad nativeAd: AdTimingNativeAd) {
     print(@"NativeAd Did Load")
     self.nativeAd = nativeAd

/// Invoked when the call to load an ad has failed.
/// Parameter error contains the reason for the failure.
func adtimingNativeDidFail(toLoad native: AdTimingNative, withError: error: Error) {
     print(@"NativeAd Did Fail")

/// Invoked when the Ad begins to show.
func adtimingNativeWillExposure(_ native: AdTimingNative) {
     print(@"NativeAd Will Exposure")

/// Invoked when the ad finishes playing.<
func adtimingNativeDidClick(_ native: AdTimingNative) {
     print(@"NativeAd Did Click")


Step 2. Load Native Ad

Invoke loadAd method to request and cache the Native Ad before it is going to be shown to users. It is strongly recommended to invoke this method a short while before the ad is to be shown.

[self.native loadAd];

Notes: The load method can be called multiple times at any time, but we do not recommend continuous requests within a short period of time. Making many requests in a short period of time makes no sense because the inventory's availability is unlikely to change much over this period. 

Step 3. Show Native Ad

Invoke the following method to serve a Native ad to your users:

self.nativeView.hidden = NO;
self.nativeView.nativeAd = self.nativeAd;
self.iconView.image =[UIImage imageWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:nativeAd.iconUrl]]];
self.titleLabel.text = nativeAd.title;
self.bodyLabel.text = nativeAd.body;
self.nativeView.isHidden = false
self.nativeView.nativeAd = self.nativeAd!
self.iconView.image = UIImage(data: try! Data(contentsOf: URL(string: self.nativeAd?.iconUrl ?? "")!))
self.titleLabel.text = self.nativeAd?.title
self.bodyLabel.text = self.nativeAd?.body
Was this article helpful?
1 out of 1 found this helpful



Please sign in to leave a comment.