-
Notifications
You must be signed in to change notification settings - Fork 0
Implementation Guide: iOS SDK
This tutorial requires an activated AdFlake.com account as well as a minimum familiarity with ObjectiveC, iOS development and Xcode project configuration.
The following five steps will enable your application to utilize AdFlake's awesome features.
On iOS we're providing the source code rather than a precompiled library. Simply drag the AdFlake-SDK
folder into your Xcode project.
Before you compile your project a modification of the file AdFlakeConfiguration.h
is necessary. Simply enable the defines of the ad networks you want to enable.
To enable Google AdMob, open the AdFlakeConfiguration.h
and change the line:
//#define AdFlake_Enable_SDK_GoogleAdMob
to
#define AdFlake_Enable_SDK_GoogleAdMob
We are currently in contact with our supported ad networks to determine if we can package the ad network SDKs in a future release.
We're using TouchJSON for JSON parsing. If you're already using TouchJSON in your project you can skip this step.
To successfully build drag the TouchJSON
redistribution folder bundled with the AdFlake SDK into your Xcode project.
Most ad network SDKs require additional system frameworks. Add the following system frameworks which are required by most of the ad network SDK's:
- AddressBook
- AudioToolbox
- AVFoundation
- CoreLocation
- libsqlite3
- libz
- MapKit
- AdSupport
The following additional frameworks are required by the iAd adapter:
- iAd
- QuartzCore
- SystemConfiguration
For distribution on older iOS versions some of the system frameworks have to be weak linked. It is possible that additional system frameworks have to be added, if your project does not build, consult the ad network's implementation guide line.
If no specific ad network adapter is enabled (by modifying the AdFlakeConfiguration.h
file) your app will only display AdFlake House Ads and Apple iAds.
Registering with an ad network and including their SDK into your project together with the AdFlake SDK enable the app to show the specified networks ads.
Don't forget to configure your ad networks on AdFlake.com and set the network traffic allocation for the specified ad providers through the AdFlake ad network settings and you are good to go.
Finally, to display the mediated ads simply implement AdFlakeDelegate
’s two requirements, request an AdFlakeView
and add it your view hierarchy.
- (void)viewDidLoad {
[super viewDidLoad];
self.adView = [AdFlakeView requestAdFlakeViewWithDelegate:self];
self.adView.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin|UIViewAutoresizingFlexibleRightMargin;
[self.view addSubview:self.adView];
}
- (NSString *)adFlakeApplicationKey {
return YOUR_AD_FLAKE_APPLICATION_SDK_KEY;
}
- (UIViewController *)viewControllerForPresentingModalView {
return [UIApplication sharedApplication].keyWindow.rootViewController;
}
- (void)applicationDidFinishLaunching:(UIApplication *)application {
AdFlakeView *adFlakeView = [AdFlakeView requestAdWhirlViewWithDelegate:self];
[self.view addSubview:adFlakeView];
}
Ads from different ad networks can have different sizes for example AdMob’s banner is 320x48 while Millennial Media’s is 320x53.
AdFlakeView
’s default banner size is 320x50 and by design any trimming or expansion to precisely fit [AdFlakeView actualAdSize]
is up to the app.
- (void)adFlakeDidReceiveAd:(AdFlakeView *)adFlakeView {
CGSize adSize = [adView actualAdSize];
CGRect newFrame = adView.frame;
newFrame.size = adSize;
newFrame.origin.x = (self.view.bounds.size.width - adSize.width)/ 2;
adView.frame = newFrame;
}
Some ad networks including iAd will vary their ad dimensions with device orientation. If your app supports rotation you must forward orientation changes to AdFlakeView by invoking AdFlakeView.rotateToOrientation: within your UIViewController’s should/willAutorotateToInterfaceOrientation: implementation and then refit as per 6.1. If your app’s notion of orientation somehow differs from UIDevice.orientation you must also implement AdFlakeDelegate.adFlakeCurrentOrientation to return the appropriate value.