Native Ads (Cross Promotion)

Native ads are flexible ad units which are stored in a TDNativeAdvert variable.

1. Register a placement tag

To begin preparations for fetching a native ad, go back to your AppDelegate.m/AppDelegate.swift where you had setup the Tapdaq SDK, and add modify it to look like this:

Objective-C
Swift
// Objective-C
TDProperties *tapdaqProps = [[TDProperties alloc] init];

TDPlacement *nativeTag = [[TDPlacement alloc] initWithAdTypes:TDAdType1x1Large forTag:@"my_native_tag"];
[tapdaqProps registerPlacement:nativeTag];

[[Tapdaq sharedSession] setApplicationId:@"YOUR_APP_ID"
                               clientKey:@"YOUR_CLIENT_KEY"
                              properties:tapdaqProps];

Note: Here we use the example of a @"my_native_tag", but you can use any custom string e.g. @"my_custom_tag".

If you want to use multiple placement tags in your application, simply instantiate multiple TDPlacement objects and register them to TDProperties, like so:

Objective-C
Swift
// Objective-C
TDPlacement *nativeTag = [[TDPlacement alloc] initWithAdTypes:TDAdType1x1Large forTag:@"my_native_tag"];
[tapdaqProps registerPlacement:nativeTag];

TDPlacement *anotherNativeTag = [[TDPlacement alloc] initWithAdTypes:TDAdType1x1Large forTag:@"my_custom_tag"];
[tapdaqProps registerPlacement:anotherNativeTag];

2. Load the native ad

Once that is done, navigate to the header file that you want the native ad to appear in (e.g. MyViewController.h) and add the following import statement at the top of the file:

Objective-C
Swift
// Objective-C
#import <Tapdaq/Tapdaq.h>

@interface MyViewController : UIViewController <TapdaqDelegate>

The above code imports Tapdaq to the class, and declares that we will conform to the TapdaqDelegate protocol.

Please note that you only need to provide import statement once per header file.

Next, add the following command to the implementation file (e.g. MyViewController.m):

Objective-C
Swift
// Objective-C
- (void)viewDidLoad {
    [super viewDidLoad];
    [[Tapdaq sharedSession] setDelegate:self];
}

- (void)myMethod {
    [[Tapdaq sharedSession] loadNativeAdvertForPlacementTag:@"my_native_tag"
                                                     adType:TDNativeAdType1x1Large];
}

Here are a list of all the possible TDNativeAdTypes.

Note: Ads should only be requested once the Tapdaq delegate method -didLoadConfig has been called. This ensures Tapdaq is initialised and ready to begin loading ads. Requesting ads prior to Tapdaq initialising will result in failed ad requests

3. Fetch the native ad

Here we set the Tapdaq delegate to this class, this will help us know when an ad is successfully loaded. Once that is done, implement the following:

Objective-C
Swift
// Objective-C
- (void)didLoadNativeAdvertForPlacementTag:(NSString *)tag adType:(TDNativeAdType)nativeAdType {    
    if ([tag isEqualToString:@"my_native_tag"] && nativeAdType == TDNativeAdType1x1Large) {

        TDNativeAdvert *nativeAd = [[Tapdaq sharedSession] getNativeAdvertForPlacementTag:@"my_native_tag"
                                                                                   adType:TDNativeAdType1x1Large];
    }
}

You can now create a custom UI to display the TDNativeAdvert object.

4. Sending the impression and click

The benefit of using native adverts is you have full control over the UI, but you must explicitly tell Tapdaq when an impression and click occurs.

If these methods below are not implemented, you will not see impressions and clicks in your app's performance page.

Impression

An impression should be registered each time the advert is presented to the user.

To trigger an impression, use the following:

Objective-C
Swift
// Objective-C
[nativeAdvert triggerImpression];

Click

A click will not only just register, but also direct the user to where the user should go after clicking the advert, this can be to the App Store, a deeplink, etc.

To trigger a click, use the following:

Objective-C
Swift
// Objective-C
[nativeAdvert triggerClick];

Build and run your application to test the ad displays correctly.

5. Native ad sizes

Below are the possible advert types we support. Each ad type has a "small", "medium" or "large" sizing, this determines the size of the advert you are fetching.

If you want a square advert to appear in a small part of the screen real-estate, we would advise using TDAdType1x1Small, but if you want a square advert to cover the majority of the screen real-estate, you should opt for TDAdType1x1Large.

The pixel size of each advert is relative to the resolution of the device. An iPhone 6 Plus (3x resolution) will display an image 3 times the size to that of an iPhone 3gs (1x).

Below is a table of each ad type and the largest possible pixel dimensions to give you a guideline of what image size to expect.

TDAdType Width (px) Height (px)
TDAdType1x1Large 750 750
TDAdType1x1Medium 375 375
TDAdType1x1Small 150 150
TDAdType2x1Large 1800 900
TDAdType2x1Medium 900 450
TDAdType2x1Small 360 180
TDAdType1x2Large 900 1800
TDAdType1x2Medium 450 900
TDAdType1x2Small 180 360
TDAdType2x3Large 960 1440
TDAdType2x3Medium 480 720
TDAdType2x3Small 192 288
TDAdType3x2Large 1440 960
TDAdType3x2Medium 720 480
TDAdType3x2Small 288 192
TDAdType5x1Large 1800 360
TDAdType5x1Medium 900 180
TDAdType5x1Small 360 72
TDAdType1x5Large 360 1800
TDAdType1x5Medium 180 900
TDAdType1x5Small 72 360

Need help?

If you are having any problems integrating, feel free to contact us on [email protected] and we will be more than happy to help.

What's next?

Now that you have successfully integrated a native ad into your app, what would you like to do next?