Integrating Banner/MREC Ads
Before continuing, ensure you have integrated the IASDKCore module here.
Importing the SDK
- Import the following IASDK module into your desired view controller:
#import <IASDKCore/IASDKCore.h>
Adding Properties
- Each IASDK module should be retained by the “client side”, hence their properties should be added. For example:
@property (nonatomic, strong) IAAdSpot *adSpot;
@property (nonatomic, strong) IAViewUnitController*viewUnitController;
@property (nonatomic, strong) IAMRAIDContentController*mraidContentController;
- Create the user data object for better ad targeting:
IAUserData *userData =
[IAUserData build:^(id _Nonnull builder) {
builder.age = 34;
builder.gender = IAUserGenderTypeMale;
builder.zipCode = @"90210";
}];
IASDKCore.sharedInstance.userData = userData;
The initialization is performed via builder block, that the block runs on the same thread that it is invoked from, and is synchronous (like the enumerateObjectsUsingBlock
iOS method).
As a result, the special block treatment (such as weak references, etc...) is not needed.
Creating the Ad Request Object
- The ad request object initialization:
IAAdRequest *adRequest =
[IAAdRequest build:^(id _Nonnull builder) {
builder.useSecureConnections = NO;
builder.spotID = @"YOUR SPOT ID";
builder.timeout = 10;
}];
To send secure requests only, set useSecureConnections to YES
Initializing the MRAID Content Controller
IAMRAIDContentController *mraidContentController =
[IAMRAIDContentController build: ^(id<IAMRAIDContentControllerBuilderh> _Nonnull builder) {
builder.MRAIDContentDelegate = self; // A delegate should be passed in order to get video content related callbacks;
}];
self.mraidContentController = mraidContentController; // The MRAID Content ControllerPage should be retained by a client side;
Declaring Your View Controller
- Declare your view controller as conforming to
IAMRAIDContentDelegate
protocol:
@interface YourViewController () <IAMRAIDContentDelegate>
Refer to this page for a full explanation of the MRAID Content Delegate Protocol.
Initializing the View Unit Controller
IAViewUnitController *viewUnitController =
[IAViewUnitController build:^(id<IAViewUnitControllerBuilder> _Nonnull builder) {
builder.unitDelegate = self;
// all the required content controllers should be added to the desired unit controller:
[builder addSupportedContentController:self.mraidContentController];
}];
self.viewUnitController = viewUnitController; // the View Unit Controller should be retained by a client side;
Declaring Your View Controller
- Declare your view controller as conforming to
IAUnitDelegate
protocol:
@interface YourViewController () <IAUnitDelegate, IAMRAIDContentDelegate>
Refer to this page for a full explanation of the Unit Delegate Protocol.
Initializing the Placement (previously known as Ad Spot)
- Initialize your Placement:
IAAdSpot *adSpot = [IAAdSpot build:^(id<IAAdSpotBuilder> _Nonnull builder) {
builder.adRequest = adRequest; // pass here the ad request object;
// all the supported (by a client side) unit controllers,
// (in this case - view unit controller) should be added to the desired ad spot:
[builder addSupportedUnitController:self.viewUnitController];
}];
self.adSpot = adSpot; // the Ad Spot should be retained by a client side;
Fetching the Ad
- Fetch the ad:
// declare a weak property, because of block:
__weak typeof(self) weakSelf = self;
[self.adSpot fetchAdWithCompletion:^(IAAdSpot * _Nullable adSpot, IAAdModel * _Nullable adModel, NSError * _Nullable error) {
if (error) {
NSLog(@"Failed to get an ad: %@\n", error);
} else {
if (adSpot.activeUnitController == weakSelf.viewUnitController) {
[weakSelf.viewUnitController showAdInParentView:weakSelf.view];
}
}
}];
You have now finished integrating Banner/MREC Ads!
Integrating Interstitial Ads
Before continuing, ensure you have integrated the IASDKCore module here.
- Import the following IASDK module into your desired view controller:
#import <IASDKCore/IASDKCore.h>
- Retain the DT Exchange SDK entities. Declare properties for the:
Placement (Ad Spot)
Unit Controller
Video + MRAID content controllers
@property (nonatomic, strong) IAAdSpot *adSpot;
@property (nonatomic, strong) IAFullscreenUnitController *unitController;
@property (nonatomic, strong) IAVideoContentController *videoContentController;
@property (nonatomic, strong) IAMRAIDContentController *mraidContentController;
- Create the user data object for better ad targeting (optional)
IAUserData *userData =
[IAUserData build:^(id _Nonnull builder) {
builder.age = 34;
builder.gender = IAUserGenderTypeMale;
builder.zipCode = @"90210";
}];
IASDKCore.sharedInstance.userData = userData;
The initialization is performed via builder block - the block runs on the same thread that it is invoked from and is synchronous (like the enumerateObjectsUsingBlock
iOS method).
As a result, the special block treatment (such as weak references, etc.) is not required
- Create the ad request
IAAdRequest *adRequest =
[IAAdRequest build:^(id _Nonnull builder) {
builder.spotID = @"YOUR Interstitial_SPOT ID";
builder.timeout = 5;
builder.useSecureConnections = NO;
}];
//You can also call the mute through the static object
//In both cases, the result is the same:
IASDKCore.sharedInstance().muteAudio = YES
To force sending the secure requests only, set the useSecureConnections
property to YES
. Otherwise the DT Exchange SDK evaluates whether it can send the unsecure request.
- Initialize the Video Content Controller
IAVideoContentController *videoContentController =
[IAVideoContentController build:
^(id _Nonnull builder) {
builder.videoContentDelegate = self;
// A delegate should be passed in order to get video content related callbacks;
}];
self.videoContentController = videoContentController;
// The Video Content ControllerPage should be retained by a client side;
- Declare your View Controller Conforms to the
IAVideoConetntDelegate
Protocol
@interface YourViewController ()<IAVideoContentDelegate>
Click here for a full explanation of the Video Content Delegate Protocol.
- Initialize the MRAID Content Controller
IAMRAIDContentController *mraidContentController =
[IAMRAIDContentController build:
^(id _Nonnull builder) {
builder.MRAIDContentDelegate = self; // a delegate should be passed in order to get video content related callbacks;
}];
self.mraidContentController = mraidContentController; // the MRAID Content ControllerPage should be retained by a client side;
8. Declare your view controller conforms to IAMRAIDContentDelegate
Protocol
@interface YourViewController () <IAVideoContentDelegate, IAMRAIDContentDelegate>
Click here for a full explanation of the MRAID Content Delegate Protocol.
9. Initialize the Fullscreen Unit Controller
IAFullscreenUnitController *fullscreenUnitController =
[IAFullscreenUnitController build:^(id _Nonnull builder)
{
builder.unitDelegate = self;
// all the needed content controllers should be added to the desired unit controller:
[builder addSupportedContentController:self.videoContentController];
[builder addSupportedContentController:self.mraidContentController];
}];
self.unitController = fullscreenUnitController; // the Fullscreen Unit Controller should be retained by a client side;
10. Declare your view controller conforms to IAUnitDelegate
Protocol
@interface YourViewController () <IAVideoContentDelegate, IAMRAIDContentDelegate, IAUnitDelegate>
Click here for a full explanation of the Unit Delegate Protocol.
11. Initialize your Placement (Ad Spot)
IAAdSpot *adSpot = [IAAdSpot build:^(id _Nonnull builder) {
builder.adRequest = adRequest; // pass here the ad request object;
[builder addSupportedUnitController:self.unitController];
}];
self.adSpot = adSpot;
// The Ad Spot should be retained by a client side;
Fetching the Ad
// declare a weak property, because of block:
__weak typeof(self) weakSelf = self;
[self.adSpot fetchAdWithCompletion:^(IAAdSpot * _Nullable adSpot, IAAdModel * _Nullable adModel, NSError * _Nullable error) {
if (error) {
NSLog(@"Failed to get an ad: %@\n", error);
} else {
if (adSpot.activeUnitController == weakSelf.viewUnitController) {
[weakSelf.unitController showAdAnimated:YES completion:nil];
}
}
}];
You have now finished integrating Video Ads!
Integrating Rewarded Ads
Before continuing, ensure you have integrated the IASDKCore module here.
- Import the following IASDK module into your desired view controller:
#import <IASDKCore/IASDKCore.h>
- Retain the DT Exchange SDK entities. Declare a properties for the:
- Placement (Ad Spot)
- Unit controller
- Video + MRAID content controllers
@property (nonatomic, strong) IAAdSpot *adSpot;
@property (nonatomic, strong) IAFullscreenUnitController *unitController;
@property (nonatomic, strong) IAVideoContentController *videoContentController;
@property (nonatomic, strong) IAMRAIDContentController *mraidContentController;
- Create the user data object for a better ad targeting (optional):
IAUserData *userData = [IAUserData build:^(id _Nonnull builder)
{
builder.age = 34;
builder.gender = IAUserGenderTypeMale;
builder.zipCode = @"90210";
}];
IASDKCore.sharedInstance.userData = userData;
The initialization is performed via builder block - the block runs on the same thread that it is invoked from and is synchronous (like the enumerateObjectsUsingBlock
iOS method).
As a result, the special block treatment (such as weak references, etc...) is not required.
- Create the ad request:
IAAdRequest *adRequest = [IAAdRequest build:^(id _Nonnull builder)
{
builder.spotID = @"YOUR SPOT ID";
builder.timeout = 5;
builder.useSecureConnections = NO;
}];
To force sending the secure requests only, set the useSecureConnections
property to YES
. Otherwise the DT Exchange SDK evaluates whether it can send the unsecure request.
//You can also call the mute through the static object
//In both cases, the result is the same:
IASDKCore.sharedInstance().muteAudio = YES
- Initialise the Video Content Controller:
IAVideoContentController *videoContentController = [IAVideoContentController build:^(id _Nonnull builder)
{
builder.videoContentDelegate = self; // A delegate should be passed in order to get video content related callbacks;
}];
self.videoContentController = videoContentController;
// The Video Content ControllerPage should be retained by a client side
- Declare your view controller conforms to the
IAVideoContentDelegate
protocol:
@interface YourViewController ()<IAVideoContentDelegate>
Click here for a full explanation of the Video Content Delegate Protocol.
- Initialise the MRAID Content Controller:
IAMRAIDContentController *mraidContentController = [IAMRAIDContentController build:^(id _Nonnull builder)
{
builder.MRAIDContentDelegate = self; // A delegate should be passed in order to get video content related callbacks;
}];
self.mraidContentController = mraidContentController;
// The MRAID Content ControllerPage should be retained by a client side
- Declare your view controller conforms to
IAMRAIDContentDelegate
protocol:
@interface YourViewController () <IAVideoContentDelegate, IAMRAIDContentDelegate>
Click here for a full explanation of the MRAID Content Delegate Protocol.
- Initialise the Fullscreen Unit Controller:
IAFullscreenUnitController *fullscreenUnitController = [IAFullscreenUnitController build:^(id _Nonnull builder)
{
builder.unitDelegate = self; // All the required content controllers should be added to the desired unit controller:
[builder addSupportedContentController:self.videoContentController];
[builder addSupportedContentController:self.mraidContentController];
}];
self.unitController = fullscreenUnitController;
// The Fullscreen Unit Controller should be retained by a client side;
- Declare your view controller conforms to
IAUnitDelegate
protocol:
@interface YourViewController () <IAVideoContentDelegate, IAMRAIDContentDelegate, IAUnitDelegate>
Click here for a full explanation of the Unit Delegate Protocol.
- Initialize your Placement (Ad Spot):
IAAdSpot *adSpot = [IAAdSpot build:^(id _Nonnull builder) {
builder.adRequest = adRequest; // pass here the ad request object;
[builder addSupportedUnitController:self.unitController];
}];
self.adSpot = adSpot; // the Ad Spot should be retained by a client side;
Fetching
Fetch the ad:
// Declare a weak var, because of a retained block:
__weak typeof(self) weakSelf = self;
[self.adSpot fetchAdWithCompletion:^(IAAdSpot * _Nullable adSpot, IAAdModel * _Nullable adModel, NSError * _Nullable error) {
if (!error) {
[weakSelf.unitController showAdAnimated:YES completion:nil];
}
}];
Mandatory Protocol Implementations
- A view controller for ad (and other related modal screens) presentation.
- (UIViewController * _Nonnull)IAParentViewControllerForUnitController:(IAUnitController * _Nullable)unitController
{
return self;
// In case 'self' is a UIViewController subclass;
}
- Rewarded ad callback.
- (void)IAAdDidReward:(IAUnitController * _Nullable)unitController
{
NSLog(@"The ad did reward.");
}
You have now completed the integrating Rewarded Ads.
Integrating All-in-One
This section describes how to support all non-native ads types and content in one integration.
Init and Fetch
Before continuing, ensure you have integrated the IASDKCore module here.
- Import the following IASDK module into your desired view controller:
#import <IASDKCore/IASDKCore>.h
- Create a properties for all types of controllers and for all content controllers.
For example:
Creating Properties
@property (nonatomic, strong) IAAdSpot *adSpot;
@property (nonatomic, strong) IAViewUnitController *viewUnitController;
@property (nonatomic, strong) IAFullscreenUnitController *fsUnitController;
@property (nonatomic, strong) IAMRAIDContentController *mraidContentController;
@property (nonatomic, strong) IAVideoContentController *videoContentController;
Creating the User Data Object
- Create the user data object for better ad targeting.
IAUserData *userData = [IAUserData build:^(id _Nonnull builder)
{ builder.age = 34;
builder.gender = IAUserGenderTypeMale;
builder.zipCode = @"90210";
}];
IASDKCore.sharedInstance.userData = userData;
The initialization is performed via builder block - the block runs on the same thread that it is invoked from, and is synchronous (like the enumerateObjectsUsingBlock iOS method).
As a result, the special block treatment (such as weak references, etc...) is not needed.
Initializing the Ad Request Object
- The ad request object initialization
IAAdRequest *adRequest = [IAAdRequest build:^(id _Nonnull builder)
{
builder.useSecureConnections = NO;
builder.spotID = @"YOUR SPOT ID";
builder.timeout = 10;
}];
To send secure requests only, please set useSecureConnections to YES.
Initializing the Controller
- Initialize the MRAID Content Controller
IAMRAIDContentController *mraidContentController = [IAMRAIDContentController build:^(id _Nonnull builder)
{
builder.MRAIDContentDelegate = self; // A delegate should be passed in order to get video content related callbacks;
}];
self.mraidContentController = mraidContentController;
// The MRAID Content ControllerPage should be retained by a client side
Declaring Your View Controller
Declare your view controller as conforming to IAMRAIDContentDelegate protocol
@interface YourViewController () <IAMRAIDContentDelegate>
Refer to this page for a full explanation of the MRAID Content Delegate Protocol.
Initializing the Video Content Controller
- Initialize the Video Content Controller
IAVideoContentController *videoContentController = [IAVideoContentController build:^(id _Nonnull builder)
{
builder.videoContentDelegate = self; // A delegate should be passed in order to get video content related callbacks;
}];
self.videoContentController = videoContentController;
// The Video Content ControllerPage should be retained by a client side
Declaring Your View Controller
Declare your view controller as conforming to IAVideoContentDelegate protocol
@interface YourViewController () <IAMRAIDContentDelegate, IAVideoContentDelegate>
Refer to this page for a full explanation of the Video Content Delegate Protocol.
Initializing the View Unit Controller
- Initialize the View Unit Controller
IAViewUnitController *viewUnitController = [IAViewUnitController build:^(id <IAViewUnitControllerBuilder>_Nonnull builder)
{
builder.unitDelegate = self; // All the required content controllers should be added to the desired unit controller:
[builder addSupportedContentController:self.videoContentController];
[builder addSupportedContentController:self.mraidContentController];
}];
self.viewUnitController = viewUnitController; // the View Unit Controller should be retained by a client side;
Initializing the Fullscreen Unit Controller
- Initialize the Fullscreen Unit Controller
IAFullscreenUnitController *fullscreenUnitController = [IAFullscreenUnitController build:^(id _Nonnull builder)
{
builder.unitDelegate = self; // All the required content controllers should be added to the desired unit controller:
[builder addSupportedContentController:self.videoContentController];
[builder addSupportedContentController:self.mraidContentController];
}];
self.unitController = fullscreenUnitController;
// The Fullscreen Unit Controller should be retained by a client side;
@interface YourViewController () <IAUnitDelegate, IAMRAIDContentDelegate, IAVideoContentDelegate>
Refer to this page for a full explanation of the Unit Delegate Protocol.
Initializing the Placement (previously known as Ad Spot)
IAAdSpot *adSpot = [IAAdSpot build:^(id _Nonnull builder)
{
builder.adRequest = adRequest; // Pass here the ad request object;
// All the supported (by a client side) unit controllers:
[builder addSupportedUnitController:self.viewUnitController];
[builder addSupportedUnitController:self.fsUnitController];
}];
self.adSpot = adSpot;
// The Ad Spot should be retained by a client side
Fetching the Ad
// Declare a weak property, because of block:
__weak typeof(self) weakSelf = self; [self.adSpot fetchAdWithCompletion:^(IAAdSpot* _Nullable adSpot, IAAdModel * _Nullable adModel, NSError * _Nullable error)
{
if (error)
{
NSLog(@"Failed to get an ad: %@\n", error);
} else
{
// If is in-view ad unit response, show in view:
if (adSpot.activeUnitController == weakSelf.viewUnitController)
{
[weakSelf.viewUnitController showAdInParentView:weakSelf.view];
}
// If is fullscreen ad unit response, show as fullscreen:
else if (adSpot.activeUnitController == weakSelf.fsUnitController)
{
[weakSelf.fsUnitController showAdAnimated:YES completion:nil];
}
}
}];
You have now completed the integration.