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 8.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.
  • NSPhotoLibraryAddUsageDescription: This feature wants to add a photo to your library.
  • 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. Enable Bitcode (Optional)

Apple introduced ‘App Thinning’ in iOS 9, which allows for compiling an app as ‘bitcode’, or an intermediate representation that on-demand compiles for the delivery device from the App Store. If you wish utilize App Thinning, you may do so by navigating to your target’s “Build Settings” and changing the value of Enable Bitcode to Yes.

Please note that the bitcode version in iOS 11 is not backwards-compatible with Xcode v8.3.3 and below. Please upgrade to Xcode v9.0+ to avoid bitcode compatibility errors, or disable bitcode in your Xcode v7.x or v8.x project.

7. Set up the AppSettings configuration for the SDK

The AppSettings object is used to configure top-level SDK information at the time of initialization. In particular it controls site ID and optionally, COPPA settings.

MMAppSettings* appSettings = [[MMAppSettings alloc] init];
appSettings.siteId = <YOUR_SITE_ID>;

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.

10. Turn on In-App Purchases for Storekit support (optional).

If an ad contains a link to the App Store, using the StoreKit.framework will open the link and process in-app purchases within a modal dialog in your app. This means your users are able to make purchases without ever leaving your app. If your app does not link StoreKit.framework, clicking on an ad that contains a link to the store will launch the App Store, causing your users to navigate away away from your app. Please note that in order to support StoreKit.framework, your app must have In-App Purchase capability turned on.

For more information on StoreKit, please refer to StoreKit.framework documentation. To learn more about In-App Purchases and how to turn them on for your app, please refer to the Adding Capabilities Guide.

Additional Topics