NextGen SDK | iOS | MoPub Integration

Integration Guide for Publishers with MoPub as a Primary Ad Server

(iOS SDK version 21.1.5)

Important Details About GDPR

As a publisher, you should integrate a Consent Management Platform (CMP) and request for vendor and purpose consents as outlined in IAB Europe’s Mobile In-App CMP API v1.0: Transparency & Consent Framework. You can find a reference implementation of a web-based CMP and the corresponding native wrappers here in the IAB’s GDPR-Transparency-and-Consent-Framework.

If you are embedding your own custom CMP, the collected end-user consent information needs to be stored in NSUserDefaults using the following keys:

Key Type Description
IABConsent_CMPPresent BOOL

Set to “YES” if a CMP that follows the IAB specification is present in the application.

IABConsent_SubjectToGDPR NSString

1” = Subject to GDPR
0” = Not subject to GDPR
-1” = Undetermined (default before initialization)

IABConsent_ConsentString

NSString

Base64-encoded consent string as defined in Consent string and vendor list format v1.1
IABConsent_ParsedPurposeConsents NSString String of “0”s and “1”s, where the character at position N indicates the consent status to purposeID N as defined in the Global Vendor List
IABConsent_ParsedVendorConsents

NSString

String of “0”s and “1”s, where the character at position N indicates the consent status to vendorID N as defined in the Global Vendor List

Example code

// User is not subject to GDPR
[[NSUserDefaults standardUserDefaults] setObject:@"0" forKey:@"IABConsent_SubjectToGDPR"];

Important Note About Fullscreen Adspaces

Currently, only the Interstitial Multi-Ad Format is compatible for Fullscreen Adspaces with Smaato NextGen SDK. In order to monetize your fullscreen Adspaces in SPX with Smaato NextGen SDK, you need to select the option for Interstitial (Display & Video). All other Fullscreen options will not work at this time.

Please check if the Interstitial (Display & Video) feature is enabled in your SPX account. If you do not see the option for Interstitial (Display & Video) in the Ad Format dropdown, please contact your Smaato Account Manager to enable this.

  • When creating your Fullscreen Adspaces in SPX, choose the Interstitial (Display & video) option as the Ad format. (Image 1)
  • For the Creative Type you will have three options to choose from (Image 2):
    • Display Only for Rich Media Ads.
    • Video Only for Video Ads.
    • Display and Video will support either Rich Media or Video Ads.

Image 1: Ad Format dropdown selection

Image 2: Creative Type dropdown selections

Ads for Testing Purposes

Publisher ID: 1100042525  
Adspace ID Type Description
130626424 Rich Media Banner / Med-rect / Leaderboard / Skyscraper
130635694 Static Image Banner / Med-rect / Leaderboard / Skyscraper
130635706 MRAID Banner / Med-rect / Leaderboard / Skyscraper
130626426 Rich Media / Video Interstitial (Video with an end-card + Rich Media Interstitial for 320×480, 480×320, 1024×768 & 768×1024)
130626427 Video Skippable Video
130626428 Rewarded Rewarded Video
130635048 Rewarded Rewarded Video without an end-card

MoPub Dashboard Setup

1. Go to the MoPub Dashboard – https://app.mopub.com/networks

2. Click on “New network” button

3. Choose “Custom SDK network” from the bottom of the list

4. Set the desired parameters in the next two tabs.

5. On “App & ad unit setup” tab, set the following: 

    • Custom event classes:
      • For Banner Ads: SMAMoPubSmaatoBannerAdapter
      • For Interstitial Ads: SMAMoPubSmaatoInterstitialAdapter
      • For Rewarded Video Ads: SMAMoPubSmaatoRewardedVideoAdapter
    • Custom event class data:
      • {"adspaceId":"<YOUR_SPX_ADSPACE_ID>"}

SDK Integration

With the modular structure of Smaato’s NextGen SDK, you can select different integration options. The following are configuration examples for your project Podfile:

Banner Ads (with Rich Media support)

pod 'smaato-ios-sdk/Banner', podspec: 'https://s3.amazonaws.com/smaato-sdk-releases/ios/smaato-ios-sdk-latest.podspec'
pod 'smaato-ios-sdk/Adapters/MoPub/Banner', podspec: 'https://s3.amazonaws.com/smaato-sdk-releases/ios/smaato-ios-sdk-latest.podspec'

Interstitial Ads (with Rich Media & Video support)

pod 'smaato-ios-sdk/Interstitial', podspec: 'https://s3.amazonaws.com/smaato-sdk-releases/ios/smaato-ios-sdk-latest.podspec'
pod 'smaato-ios-sdk/Adapters/MoPub/Interstitial', podspec: 'https://s3.amazonaws.com/smaato-sdk-releases/ios/smaato-ios-sdk-latest.podspec'

Rewarded Video Ads

pod 'smaato-ios-sdk/RewardedAds', podspec: 'https://s3.amazonaws.com/smaato-sdk-releases/ios/smaato-ios-sdk-latest.podspec'
pod 'smaato-ios-sdk/Adapters/MoPub/RewardedAds', podspec: 'https://s3.amazonaws.com/smaato-sdk-releases/ios/smaato-ios-sdk-latest.podspec'

Interstitial Ads (Rich Media only)

pod 'smaato-ios-sdk/Modules/Interstitial', podspec: 'https://s3.amazonaws.com/smaato-sdk-releases/ios/smaato-ios-sdk-latest.podspec'
pod 'smaato-ios-sdk/Modules/RichMedia', podspec: 'https://s3.amazonaws.com/smaato-sdk-releases/ios/smaato-ios-sdk-latest.podspec'
pod 'smaato-ios-sdk/Adapters/MoPub/Interstitial', podspec: 'https://s3.amazonaws.com/smaato-sdk-releases/ios/smaato-ios-sdk-latest.podspec'

SDK Initialization

AppDelegate.m / Objective-C

//
//  AppDelegate.m
//
 
#import "AppDelegate.h"
 
@import SmaatoSDKCore; // Import SmaatoSDKCore
 
@implementation AppDelegate
 
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    // initialize SDK first!
    SMAConfiguration *config = [[SMAConfiguration alloc] initWithPublisherId:@"<SMAATO_PUBLISHER_ID>"];
    config.httpsOnly = YES;  // allow HTTPS traffic only
    config.logLevel = kSMALogLevelError;  // log errors only   
 
    [SmaatoSDK initSDKWithConfig:config];
    
    // optional configuration
    SmaatoSDK.userGender = kSMAGenderFemale;
    SmaatoSDK.userAge = @30;
    SmaatoSDK.userSearchQuery = @"yoga, vegan, san+francisco";
    
    return YES;
}
 
@end

AppDelegate.swift / Swift

//
//  AppDelegate.swift
//
 
import UIKit
import SmaatoSDKCore
 
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {   
    var window: UIWindow?
     
    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
        // initialize SDK first!
        guard let config = SMAConfiguration(publisherId: "<SMAATO_PUBLISHER_ID>") else {
              fatalError("SDK config is nil!")
        }
        config.httpsOnly = true   // allow HTTPS traffic only
        config.logLevel = .error  // log errors only
        
        SmaatoSDK.initSDK(withConfig:config)
        
        // optional configuration
        SmaatoSDK.userGender = .male
        SmaatoSDK.userAge = 40
        SmaatoSDK.userSearchQuery = "bitcoin, lamborghini, san+francisco"
        
        return true
    }
}

This concludes the setup for Smaato’s NextGen SDK when MoPub is used as a primary ad server.

Modified: October 11, 2019 at 2:16 pm