Getting started with AdTech Mobile iOS SDK

AdTech is a powerful and easy-to-use ad mediation platform. Our goal is to serve your applications the best ads that pay the most at all time.

Demo app

A demo app can be downloaded from here that showcasing:

Prerequisites

Installation

CocoaPods

  1. Open terminal, go to your project’s root folder and execute commands:
$ cd <path_to_project_root_folder>
$ pod init
  1. Open and edit your Podfile as follow:
# Uncomment the next line to define a global platform for your project
# platform :ios, '10.0'

target 'TestADT' do
  # Comment the next line if you don't want to use dynamic frameworks
  use_frameworks!

  # Pods for TestADT
  pod 'ADTechMobile'

end
  1. Save your Podfile
  2. In your terminal, execute commands:
$ pod repo update
$ pod install
  1. Once the installation complete, launch Xcode using .xcworkspace file. Do not use .xcodeproj

Get Started

Account

  1. Go to AdTech, and create an account if you haven’t done so.
  2. Register your app’s Bundle ID to receive a unique Application ID for that app.

Setup Project

  1. Open your info.plist file, and add a new key GADApplicationIdentifier with the Application ID as string value that provided by AdTech.
<key>GADApplicationIdentifier</key>
<string>ca-app-pub-3940256099942544~1458002511</string>
  1. Allow cleartext HTTP resources by adding the key below to info.plist
<key>NSAppTransportSecurity</key>
<dict>
	<key>NSAllowsArbitraryLoads</key>
	<true/>
</dict>

Import SDK

In order to use the ADTechMobile SDK, first, you need to import the SDK into any of your class files that require it

...
#import <ADTechMobile/ADTechMobile.h>

...

Configuration

To run test ads, please configure the SDK as follow:

ADTRequestConfiguration *config = [ADTRequestConfiguration sharedConfiguration];

// Set test mode. Default is NO/false
config.testMode = YES;

// Set your test device IDs
config.testDeviceIdentifiers = @[@"TEST_DEVICE_ID"];
<Google> To get test ads on this device, set: request.testDevices = @[ @"159873bfa7c4492b56f8e610883535e0" ];
...
<ADT> Device IDFA: 8C7B62BF-7173-46A6-BB22-AF8ADDC00A07
...

// Each service will use different device ID, thus it is recommended to add both into the testDeviceIdentifiers
config.testDeviceIdentifiers = @[@"8C7B62BF-7173-46A6-BB22-AF8ADDC00A07", @"159873bfa7c4492b56f8e610883535e0"];

To retrieve IDFA, you can get it from ADTRequestConfiguration

ADTRequestConfiguration *config = [ADTRequestConfiguration sharedConfiguration];
NSString *idfa = config.advertisingID;

Select an Ad Format

Rectangular ads that appear at the top or bottom of the device screen. Banner ads stay on screen while users are interacting with the app, and can refresh automatically after a certain period of time. If you’re new to mobile advertising, they’re a great place to start.

Implement the Banner View

#import <ADTechMobile/ADTechMobile.h>

@interface ViewController ()
...
@property (nonatomic) ADTBannerView *banner;
...
@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.

    // Always test with test ads
    //ADTRequestConfiguration *config = [ADTRequestConfiguration sharedConfiguration];
    //config.testMode = YES;
    //config.testDeviceIdentifiers = @[@"159873bfa7c4492b56f8e610883535e0"]; // Sample test device ID

    // ADTBannerView can be create programmatically or use Interface Builder
    self.banner = [[ADTBannerView alloc] initWithFrame:CGRectMake(0, 0, 320, 50)];

    // The size of the ad to be returned
    self.banner.adSize = height_50;

    // The root view controller that contain this ad
    self.banner.rootViewController = self;

    // Add to a super view
    [self.view addSubview:self.banner];

    // Load ad
    [self.banner request];
}

@end

Receive Banner View ad events by conforming to the ADTBannerViewDelegate protocol


- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.

    ...
    // Set the delegate to receive ad events
    self.banner.delegate = self;
    ...
}

/// Tell delegate the banner view did receive ads
- (void)adtBannerViewDidReceiveAd:(ADTBannerView *)bannerView
{
    NSLog(@"adtBannerViewDidReceiveAd");
}

/// Tell delegate the ad request has failed. The error object will tell the reason why
- (void)adtBannerView:(ADTBannerView *)bannerView didFailToReceiveAdWithError:(NSError *)error
{
    NSLog(@"adtBannerView, error: %@", error.localizedDescription);
}

/// Tell the delegate the ad screen that launched by the banner view will dismiss
- (void)adtBannerViewWillDismissScreen:(ADTBannerView *)bannerView
{
    NSLog(@"adtBannerViewWillDismissScreen");
}

/// Tell the delegate the ad screen that launched by the banner view did dismiss
- (void)adtBannerViewDidDismissScreen:(ADTBannerView *)bannerView
{
    NSLog(@"adtBannerViewDidDismissScreen");
}

/// Tell the delegate that the banner view will launch an ad full screen
- (void)adtBannerViewWillPresentScreen:(ADTBannerView *)bannerView
{
    NSLog(@"adtBannerViewWillPresentScreen");
}

/// Tell the delegate that the banner view did launch an ad full screen
- (void)adtBannerViewDidPresentScreen:(ADTBannerView *)bannerView
{
    NSLog(@"adtBannerViewDidPresentScreen");
}

/// Tell the delegate that the app will go to background
- (void)adtBannerViewWillLeaveApplication:(ADTBannerView *)bannerView
{
    NSLog(@"adtBannerViewWillLeaveApplication");
}

Interstitial

Full-screen ads that cover the interface of an app until closed by the user. They’re best used at natural pauses in the flow of an app’s execution, such as between levels of a game or just after a task is completed.

Implement Interstitial Ad

@interface ViewController ()

@property (nonatomic) ADTInterstitial *interstitialAd;

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.

    // Always test with test ads
    //ADTRequestConfiguration *config = [ADTRequestConfiguration sharedConfiguration];
    //config.testMode = YES;
    //config.testDeviceIdentifiers = @[@"159873bfa7c4492b56f8e610883535e0"]; // Sample test device ID

    // Interstitial
    self.interstitialAd = [[ADTInterstitial alloc] init];

    // Request interstitial ad
    [self.interstitialAd request];
}

- (void)displayInterstitialAd {
    // Check if interstitial ad is ready before presenting
    if (self.interstitialAd.isReady) {
        [self.interstitialAd presentFromRootViewController:self];
    }
}

@end

Receive Interstitial ad events by conforming to ADTInterstitialDelegate protocol.

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.

    ...
    // Set delegate to receive interstitial ad events
    self.interstitialAd.delegate = self;
    ...
}

/// Tell delegate the interstitial ad did receive ads
- (void)adtInterstitialDidReceiveAd:(ADTInterstitial *)ad
{
    NSLog(@"adtInterstitialDidReceiveAd");
}

/// Tell delegate the ad request has failed. The error object will tell the reason why
- (void)adtInterstitial:(ADTInterstitial *)ad didFailToReceiveAdWithError:(NSError *)error
{
    NSLog(@"adtInterstitial failed, error: %@", error.localizedDescription);
}

/// Tell delegate a new ad screen will present
- (void)adtInterstitialWillPresentScreen:(ADTInterstitial *)ad
{
    NSLog(@"adtInterstitialWillPresentScreen");
}

/// Tell delegate the new ad screen failed to present
- (void)adtInterstitialDidFailToPresentScreen:(ADTInterstitial *)ad
{
    NSLog(@"adtInterstitialDidFailToPresentScreen");
}

/// Tell delegate the ad screen will dismiss
- (void)adtInterstitialWillDismissScreen:(ADTInterstitial *)ad
{
    NSLog(@"adtInterstitialWillDismissScreen");

    // You can reload a new interstitial ad here
    [self.interstitialAd request];
}

/// Tell delegate the ad screen did dismiss
- (void)adtInterstitialDidDismissScreen:(ADTInterstitial *)ad
{
    NSLog(@"adtInterstitialDidDismissScreen");
}

/// Tell the delegate that the app will go to background
- (void)adtInterstitialWillLeaveApplication:(ADTInterstitial *)ad
{
    NSLog(@"adtInterstitialWillLeaveApplication");
}

Native

Customizable ads that match the look and feel of your app. You decide how and where they’re placed, so the layout is more consistent with your app’s design.

Implement Native Ad

@interface NativeViewController () <ADTNativeAdDelegate>

/// The headline label outlet
@property (weak, nonatomic) IBOutlet UILabel *headlineLabel;
/// The action button
@property (weak, nonatomic) IBOutlet UIButton *callToActionButton;
/// The ad icon image view
@property (weak, nonatomic) IBOutlet UIImageView *iconImageView;
/// The native ad handle
@property (strong, nonatomic) ADTNativeAd *nativeAd;

@end

@implementation NativeViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.

    // Always test with test ads
    //ADTRequestConfiguration *config = [ADTRequestConfiguration sharedConfiguration];
    //config.testMode = YES;
    //config.testDeviceIdentifiers = @[@"159873bfa7c4492b56f8e610883535e0"]; // Sample test device ID

    // Create the native ad
    self.nativeAd = [[ADTNativeAd alloc] init];

    // Set the delegate to receive ad events
    self.nativeAd.delegate = self;

    // Request the ad
    [self.nativeAd request];
}

Receive Native ad events by conforming to ADTNativeAdDelegate protocol.

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.

    ...
    // Set delegate to receive native ad events
    self.nativeAd.delegate = self;
    ...
}

/// Tell delegate native ad did receive ad
- (void)adtNativeAdDidReceiveAd:(ADTNativeAd *)ad
{
    // Set handle to the returned native ad
    self.nativeAd = ad;

    // Create the media ad view to show ad media, could be a video or an image
    UIView *mediaAdView = [[UIView alloc] initWithFrame:CGRectMake(0, 400, UIScreen.mainScreen.bounds.size.width, UIScreen.mainScreen.bounds.size.height - 400)];
    // Add the media ad view to super view for displaying
    [self.view addSubview:mediaAdView];

    // Register views for the native ad
    [self.nativeAd registerAdView:self.view
                        mediaView:mediaAdView
                   viewController:self
                   clickableViews:@{
                       ADTNativeAdHeadlineAsset: self.headlineLabel,
                       ADTNativeAdIconAsset: self.iconImageView,
                       ADTNativeAdCallToActionAsset: self.callToActionButton
                   }];

    // Display headline if available
    if (self.nativeAd.headline) {
        self.headlineLabel.text = self.nativeAd.headline;
    }

    // Set the call to action button text
    if (self.nativeAd.callToAction) {
        [self.callToActionButton setTitle:self.nativeAd.callToAction forState:UIControlStateNormal];
    }

    // Display the icon for this ad
    if (self.nativeAd.icon) {
        self.iconImageView.image = self.nativeAd.icon;
    }

    ...
}

/// Tell delegate native ad has failed
- (void)adtNativeAd:(ADTNativeAd *)ad didFailToReceiveAdWithError:(NSError *)error
{
    NSLog(@"adtNativeAd failed, error: %@", error.localizedDescription);
}

/// Tell delegate that native ad did record impression from showing the ad
- (void)adtNativeAdDidRecordImpression:(ADTNativeAd *)ad
{
    NSLog(@"adtNativeAdDidRecordImpression");
}

/// Tell delegate native ad did finish loading all assets
- (void)adtNativeAdDidFinishLoading:(ADTNativeAd *)ad
{
    NSLog(@"adtNativeAdDidFinishLoading");
}

/// Tell delegate that native ad did record user tap
- (void)adtNativeAdDidRecordClick:(ADTNativeAd *)ad
{
    NSLog(@"adtNativeAdDidRecordClick");
}

/// Tell delegate that native ad will present a new ad screen
- (void)adtNativeAdWillPresentScreen:(ADTNativeAd *)ad
{
    NSLog(@"adtNativeAdWillPresentScreen");
}

/// Tell delegate that native ad did successfully present new ad screen
- (void)adtNativeAdDidPresentScreen:(ADTNativeAd *)ad
{
    NSLog(@"adtNativeAdDidPresentScreen");
}

/// Tell delegate that native ad will dismiss the ad screen being displayed
- (void)adtNativeAdWillDismissScreen:(ADTNativeAd *)ad
{
    NSLog(@"adtNativeAdWillDismissScreen");
}

/// Tell delegate that native ad did dismiss the ad screen
- (void)adtNativeAdDidDismissScreen:(ADTNativeAd *)ad
{
    NSLog(@"adtNativeAdDidDismissScreen");
}

/// Tell delegate that application will go to background, and transition to a new app
- (void)adtNativeAdWillLeaveApplication:(ADTNativeAd *)ad
{
    NSLog(@"adtNativeAdWillLeaveApplication");
}

Rewarded Video Ad

Ads that reward users for watching short videos and interacting with playable ads and surveys. Good for monetizing free-to-play users.

Implement Rewarded Video Ad

@interface ViewController ()

@property (strong, nonatomic) ADTRewardedAd *rewardedAd;

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.

    // Always test with test ads
    //ADTRequestConfiguration *config = [ADTRequestConfiguration sharedConfiguration];
    //config.testMode = YES;
    //config.testDeviceIdentifiers = @[@"159873bfa7c4492b56f8e610883535e0"]; // Sample test device ID

    // Create rewarded ad
    self.rewardedAd = [[ADTRewardedAd alloc] init];

    // Request ad from network
    [self.rewardedAd request];
}

- (void)displayRewardedAd
{
    // Check if rewarded ad is ready before presenting the ad
    if (self.rewardedAd.isReady) {
        [self.rewardedAd presentFromRootViewController:self];
    }
}

Receive Native ad events by conforming to ADTRewardedAdDelegate protocol.


- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.

    ...
    // Set delegate to receive events
    self.rewardedAd.delegate = self;
    ...
}

/// Tell delegate the reawarded ad did receive ads
- (void)adtRewardedAdDidReceiveAd:(ADTRewardedAd *)rewardedAd
{
    NSLog(@"adtRewardedAdDidReceiveAd");
}

/// Tell delegate the ad request has failed. The error object will tell the reason why
- (void)adtRewardedAd:(ADTRewardedAd *)rewardedAd didFailToReceiveAdWithError:(NSError *)error
{
    NSLog(@"adtRewardedAd failed: %@", error.localizedDescription);
}

/// Tells the delegate that the rewarded ad was presented.
- (void)adtRewardedAdDidPresent:(ADTRewardedAd *)rewardedAd
{
    NSLog(@"adtRewardedAdDidPresent");
}

/// Tells the delegate that the user earned a reward.
- (void)adtRewardedAdDidEarnReward:(ADTRewardedAd *)rewardedAd
{
    NSLog(@"Rewarded did earn reward");
}

/// Tells the delegate that the rewarded ad was dismissed.
- (void)adtRewardedAdDidDismiss:(ADTRewardedAd *)rewardedAd
{
    NSLog(@"adtRewardedAdDidDismiss");

    // Here is also a good place to load a new rewarded ad.
    [self.rewardedAd request];
}

top