Before You Start Make Sure:
- at least one App and Placement are added on Publisher Portal
- SDK is installed
- SDK is initialised
- Placements have “Testing” status in order to get a test ad, for testing the integration
1. Requesting ads
To request an ad you should retrieve the Placement object from the Controller.
DIOPlacement *placement = [[DIOController sharedInstance] placementWithId:@"5678"];
Then issue a new DIOAdRequest object from the Placement object:
DIOAdRequest *request = [placement newAdRequest];
To execute an Ad Request (asynchronous operation):
[request requestAdWithAdReceivedHandler:^(DIOAdProvider *adProvider) {
// Success
} noAdHandler:^(NSError *error){
// Failure
}];
You may add data about the user or the context of the ad to the Ad Request. As a best practice, we advise our publishers to add as much user data to their Ad Requests as possible. The reason is, this gives advertisers visibility into the parameters of each user within your app, and in doing so, allows advertisers to bid more intelligently. Meaning a higher CPM payout for you.
[request setContentKeywords:@[@"house of cards", @"ronaldo"]];
[adRequest setUserId:@"some user ID"];
[adRequest setBuyerId:@"some buyer ID"];
[adRequest setIABPageCats:@[@"IAB12", @"IAB6-1", @"IAB48-84"]];
[adRequest setIABSectionCats:@[@"IAB2", @"IAB61-12", @"IAB1-1"]];
In case you are requesting Banner or Medium Rectangle ads, specify the expected position of the ad on a screen as follows:
[request setPosition:DIOBannerPositionAboveTheFold];
[request setPosition:DIOBannerPositionBelowTheFold];
Note: Ad Request properties should be added prior to executing the ad request.
2. Loading ads
Use the DIOAdProvider to load the ad:
[adProvider loadAdWithLoadedHandler:^(DIOAd *ad) {
// Success
} failedHandler:^(NSError *error){
// Failure
}];
If you previously requested ad attributes like ‘Advertiser Name’ and ‘Advertiser Click URL’, you can access them as follows:
NSString *name = ad.avertiserName;
NSString *clickURL = ad.advertiserClickURL;
You also can retrieve additional data of current ad:
NSLog(@"=================== advertiserName = %@", ad.advertiserName);
NSLog(@"=================== advertiserClickURL = %@", ad.advertiserClickURL);
NSLog(@"=================== ecpm = %@", ad.ecpm);
NSLog(@"=================== crid = %@", ad.crid);
NSLog(@"=================== cid = %@", ad.cid);
NSLog(@"=================== adomain = %@", ad.adomain); // NSArray
NSLog(@"=================== auctionId = %@", ad.auctionId);
NSLog(@"=================== msessId = %@", ad.msessId);
A/B testing labels can be defined via:
[request setLabels:@[@"blue", @"red"]]
Note:
We provide GDPR compliance through the IAB’s GDPR Transparency and Consent framework. If you use a CMP that implements this IAB standard, we will be able to pick the consent state from your integrated CMP and apply it in our ad serving.