Integration Guide

The Millennial Media iOS Ad SDK provides functionality for monetizing your iOS applications. With the SDK, you can easily integrate inline, interstitial, and native ads into your application.

Requirements

  • Xcode 7.0 or higher
  • Deployment target of iOS 7.0 or higher

Adding the SDK to your project

1. Add MMAdSDK.framework to your Xcode project.

Make sure to select “Copy Items to Destination” along with all appropriate targets when copying the MMSDK files to your project.

2. Add the following required frameworks to your project.

  • AdSupport.framework
  • AudioToolbox.framework
  • AVFoundation.framework
  • CoreGraphics.framework
  • CoreLocation.framework
  • CoreTelephony.framework
  • CoreMedia.framework
  • EventKit.framework
  • EventKitUI.framework
  • Foundation.framework
  • libxml2.tbd
  • MediaPlayer.framework
  • MessageUI.framework
  • SystemConfiguration.framework
  • UIKit.framework

In earlier versions of Xcode, tbd libraries were instead dylib.

Link: How to add frameworks to your Xcode project.

Note: CoreLocation is a required framework, even if sending location data is disabled. For more information about location, see here.

3. Add required usage purpose strings to Info.plist

The SDK requires usage strings for Calendar, Reminders, Photos, Camera, and Location, which will need to be added to your Info.plist. This is required for iOS 10 support or your app will crash on some ad interactions, and may be rejected from the App Store. These keys are all added to the top level of the Info.plist as strings, and may be accessed from within Xcode 8+ as “Privacy - Usage Description". The required Info.plist keys and suggested values relating to the use of these features for ads are listed below. If your app already uses any of these features, you should use your own purpose strings.

  • NSCalendarsUsageDescription: This interaction requires calendar access.
  • NSRemindersUsageDescription: This interaction will add a reminder.
  • NSCameraUsageDescription: This feature requires using the camera.
  • NSPhotoLibraryUsageDescription: This feature requires a stored image.
  • NSLocationWhenInUseUsageDescription: This app wants to display nearby features.

Note: The SDK does not monitor location in backgrounded apps. However, if your app already uses the NSLocationAlwaysUsageDescription key, you do not also need to include the NSLocationWhenInUseUsageDescription key.

4. Add NSAllowsArbitraryLoads to Info.plist

In order to serve ads, the SDK requires that you allow arbitrary loads. In the top level of your Info.plist, add the App Transport Security Settings key as a dictionary type, and then to that dictionary, add the NSAllowsArbitraryLoads key as a boolean and set the value to Yes.

If you would like to enforce App Transport Security (ATS) for specific domains which you believe should be blacklisted from being allowed to load arbitrary content, please read Apple’s documentation on ATS configuration.

5. Add the “-ObjC” linker flag to your target.

Link: How to add the “-ObjC” linker flag to your target.

6. Disable bitcode

Apple introduced ‘App Thinning’ with iOS 9, which includes the ability to compile an app as ‘bitcode’, or an intermediate representation that allows Apple to on-demand compile for the delivery device. The SDK does not include bitcode support, which means that you must disable bitcode support. You may do this by navigating to your target’s “Build Settings” and changing the value of Enable Bitcode to No.

A future version of the SDK will enable bitcode support.

7. Set up the AppSettings configuration for the SDK (Optional)

The AppSettings object is used to configure top-level SDK information at the time of initialization, if necessary. In particular it controls COPPA settings and Site ID for Nexage integrations.

MMAppSettings* appSettings = [[MMAppSettings alloc] init];
appSettings.siteId = <Site ID>; // Only applicable if migrating from Nexage
[appSettings setCoppaCompliance:YES]; // Only required if your app must enable COPPA

After SDK initialization, you cannot replace the AppSettings object, but may modify any existing one.

8. Set up the UserSettings configuration for the SDK (Optional)

The UserSettings object is used to configure the SDK on a per-user basis, and consists entirely of targeting information. For more about these values and what they represent, see the full documentation.

MMUserSettings* userSettings = [[MMUserSettings alloc] init];
// Provide userSettings values here, as appropriate

After SDK initialization, you may reset this value using the userSettings property of the global SDK instance.

9. Initialize the SDK.

#import "AppDelegate.h"
#import <MMAdSDK/MMAdSDK.h>

@implementation AppDelegate

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
	<APP CONFIG SETUP>
	<USER CONFIG SETUP>
	[[MMSDK sharedInstance] initializeWithSettings:<APP CONFIG OBJECT> withUserSettings:<USER CONFIG OBJECT>];
	return YES;
}

Both the <APP CONFIG OBJECT> and <USER CONFIG OBJECT> are allowed to be nil if your application does not require additional configuration.

Additional Topics