Skip to content

Implementation Guide: iOS SDK

Manny edited this page Oct 6, 2013 · 12 revisions

The AdFlake for iOS SDK maximizes your app’s advertising revenue.

This tutorial requires an activate 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 awesome features.

1. AdFlake

On iOS we're providing the source code rather than a precompiled library which is to be incorporated in to your project build process. Before compilation the AdFlakeConfiguration.h , because these have dependencies to the ad network SDK's resulting in build errors.

2. TouchJSON

Incorporate the TouchJSON redistribution bundled with the AdFlake SDK.

3. System Frameworks

Add the several system frameworks which are required by the different ad network SDK's:

  • AddressBook
  • AudioToolbox
  • AVFoundation
  • CoreLocation
  • libsqlite3
  • libz
  • MapKit

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.

4. Ad Networks

If no specific ad network adapter is added your app will show only House Ads.

Registering with an ad network and incorporating the SDK into your project with AdFlake and the specific interfaces and library files will enable the app to show the specified networks ads.

Ad Network Required Files Additional Instructions
AdMob AdMob folder N/A
Google AdSense Library folder Requires implementing AdFlake delegates: googleAdSenseCompanyName, googleAdSenseAppName, googleAdSenseApplicationAppleID
Greystripe GreystripeDelegate.h, GSAdEngine.h, GSAdView.h, libGreystripeSDK.a N/A
iAd iAd framework  N/A
InMobi inMobiAdView.h, inMobiAdDelegate.h, libInMobi_iPhone.a N/A
Jumptap JumptapApi folder  Fill in the new SiteID and SpotID Jumptap settings on your app’s Ad Network Settings page.
MdotM  MdotMDelegateProtocol.h, MdotMView.h, MdotMView.m  N/A
Millenial Media Public folder  N/A
VideoEgg  VEAdFrames folder  To avoid build errors remove AdFrameView.o from the ARM and X86 sub-folders. Rename libAdFrame.a in each architecture’s sub-folder to include the architecture, as in libAdFrame-ARM.a and libAdFrame-X86.a.
ZestADZ  ZestADZ folder N/A

Set network traffic allocation for the specified ad providers through the AdFlake Ad Network settings and you are good to go.

5. AdFlakeView

Finally, to display the mediated ads simply implement AdWhirlDelegate’s two requirements, request an AdFlakeView and add it to the hierarchy.

- (NSString *)adWhirlApplicationKey {
     return _MY_AD_WHIRL_APPLICATION_KEY;
 }

- (UIViewController *)viewControllerForPresentingModalView {
     return UIWindow.rootViewController;
}

- (void)applicationDidFinishLaunching:(UIApplication *)application {
     AdFlakeView *adFlakeView = [AdFlakeView requestAdWhirlViewWithDelegate:self];
     [self.view addSubview:adFlakeView];
}

6. Development Notes

6.1 Ad Sizes

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)adWhirlDidReceiveAd:(AdWhirlView *)adWhirlView {
     [UIView beginAnimations:@”AdWhirlDelegate.adWhirlDidReceiveAd:”
     context:nil];

     [UIView setAnimationDuration:0.7];

     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;

     [UIView commitAnimations];
}

6.2 Device Orientation

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.

Clone this wiki locally