NextGen SDK | iOS | AdMob Integration

Integration Guide for Publishers with AdMob as a Primary Ad Server

(iOS SDK version 21.3.3)

 

AdMob Dashboard Setup

1. Go to the AdMob Dashboard – https://apps.admob.com/v2/mediation/groups/list

2. Click on “Create Mediation Group” button

3. Select Ad format as per your need. Possible options are Banner, Interstitial and Rewarded.

4. Set the desired parameters in the next tab.

5. On “Add Ad Unit” option under “Ad Unit“, select the ad unit that needs to be targeted with mediation.

6. Under “Ad sources“, click on “ADD CUSTOM EVENT

    • Provide Label and your desired eCPM
    • Under “Configure ad units“, provide the class name details:
      • For Banner Ads: SMAAdMobSmaatoBannerAdapter
      • For Interstitial Ads: SMAAdMobSmaatoInterstitialAdapter
      • For Rewarded Video Ads: SMAAdMobSmaatoRewardedVideoAdapter
    • Pass parameter for the SPX Adspace ID:
      • adSpaceId=<YOUR_SPX_ADSPACE_ID>

 

Integrate the NextGen SDK

First, configure your SPX account: https://spx.smaato.com/

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'
pod 'smaato-ios-sdk/Adapters/AdMob/Banner'

Interstitial Ads (with Rich Media & Video support)

pod 'smaato-ios-sdk/Interstitial'
pod 'smaato-ios-sdk/Adapters/AdMob/Interstitial'

Rewarded Video Ads

pod 'smaato-ios-sdk/RewardedAds'
pod 'smaato-ios-sdk/Adapters/AdMob/RewardedAds'

Open Terminal then go to the project directory.

cd {PATH_TO_PROJECT_DIR}

Install the pods.

pod install

 

Initialize the NextGen SDK

In the “AppDelegate.mimport SmaatoSDKCore module and configure SDK in “application:didFinishLaunchingWithOptions:

Swift
Objective-C
Swift
// AppDelegate.swift
import UIKit
import SmaatoSDKCore
 
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
     
    var window: UIWindow?
     
    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
        // initialize SDK!        
        guard let config = SMAConfiguration(publisherId: "SMAATO_PUBLISHER_ID") else {
              fatalError("SDK config is nil!")
        }
		// allow HTTPS traffic only
        config.httpsOnly = true 
		// log errors only
        config.logLevel = .error
		// ads content restriction based on age
		config.maxAdContentRating = .undefined
         
        SmaatoSDK.initSDK(withConfig:config)
		// allow the Smaato SDK to automatically get the user's location and put it inside the ad request
        SmaatoSDK.gpsEnabled = true  
 
        // optional, specific configuration        
        SmaatoSDK.userGender = .male // usually set after user logs in
        SmaatoSDK.userAge = 40 // usually set after user logs in
        SmaatoSDK.userSearchQuery = "bitcoin, lamborghini, san+francisco"
         
        return true
    }
}

Objective-C
// AppDelegate.m
#import "AppDelegate.h"
@import SmaatoSDKCore;
 
@implementation AppDelegate
 
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {   
    // initialize SDK first!    
    SMAConfiguration *config = [[SMAConfiguration alloc] initWithPublisherId:@"SMAATO_PUBLISHER_ID"];
	// allow HTTPS traffic only
    config.httpsOnly = YES;                 
	// log errors only
    config.logLevel = kSMALogLevelError;    
	// ads content restriction based on age
	config.maxAdContentRating = kSMAMaxAdContentRatingUndefined;
	[SmaatoSDK initSDKWithConfig:config];
	// allow the Smaato SDK to automatically get the user's location and put it inside the ad request
    SmaatoSDK.gpsEnabled = YES;
     
    // optional configuration    
    SmaatoSDK.userGender = kSMAGenderFemale; // usually set after user logs in
    SmaatoSDK.userAge = @30; // usually set after user logs in
    SmaatoSDK.userSearchQuery = @"yoga, vegan, san+francisco";
     
    return YES;
}

Important Note: Starting from NextGen SDK version 21.2.1, the new GPSEnabled flag allows the SDK to automatically get the user’s location when permission is given by the user. By default, this flag is set to off and the user location will not be provided in the ad request. To enable this the GPSEnabled flag must be set to yes (for objective-c) or true (for swift).

 

Important Details About GDPR

The General Data Protection Regulation (GDPR) was created to provide European users with greater transparency and control over their personal information. As a publisher, you should integrate a Consent Management Platform (CMP) and request for user, vendor, and purpose consents as outlined in IAB Europe’s Mobile In-App CMP API v1.0: Transparency & Consent Framework. You can find an example implementation of a web-based CMP and the corresponding native wrappers here in the IAB’s GDPR-Transparency-and-Consent-Framework.

You can also make 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 (Obj-C) or true (Swift) 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

Sample of GDPR Saving in NSUserDefaults

Swift
Objective-C
Swift
// User is not subject to GDPR
UserDefaults.standard.set("0", forKey: "IABConsent_SubjectToGDPR")
// Use this example above to set values for the rest of the GDPR keys

Objective-C
// User is not subject to GDPR
[[NSUserDefaults standardUserDefaults] setObject:@"0" forKey:@"IABConsent_SubjectToGDPR"];
// Use this example above to set values for the rest of the GDPR keys

 

Important Details About CCPA

The California Consumer Privacy Act (CCPA) was created to provide California consumers with greater transparency and control over their personal information.

For more information about the CCPA regulation, please check out the Smaato FAQ. You can also review the IAB’s U.S. Privacy String documentation.

For Publishers with California-Based Users

As a publisher, you need to make sure to request consent from California-based users (to give or refuse consent / to opt-out or opt-in ) about private data transfer. This answer should be saved in NSUserDefaults with key “IABUSPrivacy_String” in the US Privacy String format (CCPA Opt-Out Storage Format).

Sample of CCPA Saving in NSUserDefaults

Swift
Objective-C
Swift
// save the user's consent
private func saveCCPA(usPrivacy string: String?) {
    guard let usString = string else {
        return
    }
    UserDefaults.standard.set(usString, forKey: "IABUSPrivacy_String"
}
// call this function like this:
// saveCCPA(string: "1YNN")

Objective-C
// save the user's consent
- (void)saveCCPAUsPrivacyString:(NSString *)usString
{
    if (usString.length > 0) {
        [NSUserDefaults.standardUserDefaults setObject:usString 
         forKey:@"IABUSPrivacy_String"];
    }
}
// call this function like this:
// [saveCCPAUsPrivacyString usString:@"1YNN"]; 

NextGen SDK reads that value by key “IABUSPrivacy_String” if it exists and uses it as an optional parameter for all ad requests.

 

 

Ads for Testing Purposes

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

 


Modified: May 6, 2020 at 10:45 am