SDK Installation
Before You Start Make Sure:
Add the SDK to your XCode project
1a. Via Cocoapods
Specify in your Podfile:
target 'YourProjectName' do pod 'DIOSDK', '3.5.9' end
1b. Manually
1.b.1. Drag and drop the downloaded DIOSDK.framework into your XCode project.
1.b.2. Be sure to have “Copy items if needed” checked.
1.b.3. Click on the “+” in “Embedded Binaries” and add DIOSDK.framework.
2. Add the following item to your Info.plist file
SDK Initialization
Initialise the SDK upon application start.
Example for one of the view controllers:
#import <DIOSDK/DIOController.h> @implementation ViewController - (void)viewDidLoad { [super viewDidLoad]; [[DIOController sharedInstance] initializeWithProperties:nil appId:@"1234" completionHandler:^{ // Ready to go } errorHandler:^(NSError *error) { // Something wrong happened }]; }
Note: initialisation is an asynchronous operation.
A more advanced way to initialise the SDK is by passing a DIOInitProperties object:
DIOInitProperties *properties = [[DIOInitProperties alloc] init]; [[DIOController sharedInstance] initializeWithProperties:properties appId:@"1234" completionHandler:^{ // Success } errorHandler:^(NSError *error) { // Failure }];
Location based targeting is enabled by default, but there is a way to disable it:
[[DIOController sharedInstance] setLocationBasedTargeting:NO];
In order to disable the internal crash reporting system (this might be helpful if you use your own crash reporting system, like Crashlytics):
[properties setCrashReportsDisabled:NO]
Ads Requesting
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 }];
Note: Ad Request properties should be added prior to executing the ad request.
Extra Ad Request Parameters
There is an option to set up additional parameter to the Ad Request for ad campaign targeting and other needs:
[adRequest setCustomerId:@[@"172Rtk999"]]; [adRequest setPage:@"Food"]; [adRequest setCat:@[@"Food", @"Asia"]]; [adRequest setUserKeywords:@[@"Meal", @"Asia"]]; [adRequest setContentKeywordsFilters:@[@"Lunch", @"NY"]]; [adRequest setLabels:@[@"premium", @"main"]]; [adRequest setLanguage:@[@"en"]]; [adRequest setGroup:@[@"food lovers", @"main"]]; [adRequest setCur:@[@"usd"]]; [adRequest setYob:@"1989"]; [adRequest setGender:@"male"]; [adRequest setCustomParams:@"{\"param1\": 1122, \"param2\": \"abcd\" }"];
Note: Ad Request data should be added prior to executing the Ad Request.
Ads Loading
Use the DIOAdProvider to load the ad:
[adProvider loadAdWithLoadedHandler:^(DIOAd *ad) { // Success } failedHandler:^(NSError *error){ // Failure }];
Get Ad Response Params
There is a list of parameters which can be extracted from Shoppable Ad object (in case the parameters presence):
NSLog(@"ESPM: %f ",[self.ad ecpm]); NSLog(@"customParams: %@ ",[self.ad customParams]); NSLog(@"productCode: %@ ",[self.ad productCode]); NSLog(@"retailerTaxonomy: %@ ",[self.ad retailerTaxonomy]); NSLog(@"globalIdentifier: %@ ",[self.ad globalIdentifier]); NSLog(@"productName: %@ ",[self.ad productName]); NSLog(@"productPrice: %@ ",[self.ad productPrice]); NSLog(@"productBrand: %@ ",[self.ad productBrand]); NSLog(@"cid: %@ ",[self.ad cid]); NSLog(@"crid: %@ ",[self.ad crid]); NSLog(@"clickUrl: %@ ",[self.ad clickURL]);