NextGen SDK | iOS Integration

Integration Guide for Publishers with Smaato as a Primary Ad Server

(iOS SDK version 21.2.1)

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

Integrating an iOS App

Prerequisites

In order to integrate the NextGen SDK into your iOS project you will first need to install the following items:

Choose Ad Formats

In order to make the SDK’s binary size smaller it is split into several frameworks:

SmaatoSDKCore.framework
SmaatoSDKBanner.framework
SmaatoSDKInterstitial.framework
SmaatoSDKRewardedAds.framework
SmaatoSDKRichMedia.framework
SmaatoSDKVideo.framework
SmaatoSDKOpenMeasurement.framework
SmaatoSDKUnifiedBidding.framework

First, you need to make sure to link the application with the proper set of frameworks to allow the SDK to display the desired Ad Formats.

The table below shows possible configurations, i.e. if you want to display standard banner, link the application against the Core, Banner, Rich Media and OpenMeasurement frameworks. In this case Rich Media means HTML content rendering support.

Framework Banner / Image + Rich Media Interstitial / Image + Rich Media Interstitial / Video Interstitial / Image + Rich Media + VideoDescription Rewarded / Video
SmaatoSDKCore.framework 1 X X X X X
SmaatoSDKOpenMeasurement.framework 1 X X X X X
SmaatoSDKBanner.framework X        
SmaatoSDKInterstitial.framework   X X X  
SmaatoSDKRewardedAds.framework         X
SmaatoSDKRichMedia.framework X X   X  
SmaatoSDKVideo.framework     X X X
SmaatoSDKUnifiedBidding.framework 2 X* X* X* X* X*

Setting Up NextGen SDK

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

2.) Create and save the Xcode “Single View” project. Name it as “MyTarget“. Then close the Xcode.

3.) Next, create a file with the name “Podfile” in the project directory with one of the following snippets or their reasonable combination.

All supported Ad Formats (full Smaato SDK):

source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '8.0'
target 'MyTarget' do
   use_frameworks!
   pod 'smaato-ios-sdk'
end

Please Note: To reduce the size of your application, you may specify only the Ad Formats which you want to use.

For Banner Ads (Image & Rich Media):

source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '8.0'
target 'MyTarget' do
   use_frameworks!
   pod 'smaato-ios-sdk/Banner'
end

For Interstitial Ads (Image & Rich Media & Video):

source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '8.0'
target 'MyTarget' do
   use_frameworks!
   pod 'smaato-ios-sdk/Interstitial'
end

For Interstitial Ads (Image & Rich Media):

source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '8.0'
target 'MyTarget' do
   use_frameworks!
   pod 'smaato-ios-sdk/Modules/Interstitial'
   pod 'smaato-ios-sdk/Modules/RichMedia'
en

For Banner and Interstitial Ads (Image & Rich Media):

source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '8.0'
target 'MyTarget' do
   use_frameworks!
   pod 'smaato-ios-sdk/Modules/Banner'
   pod 'smaato-ios-sdk/Modules/Interstitial'
   pod 'smaato-ios-sdk/Modules/RichMedia'
end

For Rewarded Ads (Video):

source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '8.0'
target 'MyTarget' do
   use_frameworks!
   pod 'smaato-ios-sdk/RewardedAds'
end


4.)
Open Terminal then go to the project directory.

$ cd {PATH_TO_PROJECT_DIR}


5.)
Install the pods.

$ pod install


6.)
The “{PROJECT_NAME}.xcworkspace” file should appear in the project folder. You will then need to open the “{PROJECT_NAME}.xcworkspace” in Xcode.

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

Objective-C code

// 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>"];
    config.httpsOnly = YES;                 // allow HTTPS traffic only    
    config.logLevel = kSMALogLevelError;    // log errors only 
    [SmaatoSDK initSDKWithConfig:config];   
    SmaatoSDK.gpsEnabled = YES; // allow the Smaato SDK to automatically get the user's location and put it inside the ad request
     
    // optional configuration    
    SmaatoSDK.userGender = kSMAGenderFemale;
    SmaatoSDK.userAge = @30;
    SmaatoSDK.userSearchQuery = @"yoga, vegan, san+francisco";
     
    return YES;
}

Swift code

// 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 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)
        SmaatoSDK.gpsEnabled = true // allow the Smaato SDK to automatically get the user's location and put it inside the ad request 
 
        // optional configuration        
        SmaatoSDK.userGender = .male
        SmaatoSDK.userAge = 40
        SmaatoSDK.userSearchQuery = "bitcoin, lamborghini, san+francisco"
         
        return true
    }
}

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).

 

Steps to Integrate the Banner

1.) Add SMABannerView to ViewController in Interface Builder.

2.) Layout BannerView so that it takes enough space to display the banner of desired size (i.e. XXLarge takes 320×50 pt).

3.) In the Interface Builder, link the SMABannerView with ViewController via IBOutlet.

Objective-C code

// ViewController.h
#import "ViewController.h"
@import SmaatoSDKBanner;
 
@interface ViewController : UIViewController
@property (nonatomic, weak) IBOutlet SMABannerView *bannerView;
@end


Swift code

// ViewController.swift
import UIKit
import SmaatoSDKBanner
 
class ViewController: UIViewController { 
   @IBOutlet weak var bannerView: SMABannerView!
     
   override func viewDidLoad() {
       super.viewDidLoad()
   }
}

4.) Adopt ViewController to the SMABannerViewDelegate protocol. Then Implement the required SMABannerViewDelegate methods.

Objective-C code

// ViewController.m
#import "ViewController.h"
 
// declare the ViewController to conform the SMABannerViewDelegate protocol
 
@interface ViewController () <SMABannerViewDelegate>
@end
 
@implementation ViewController
...
#pragma mark - <SMABannerViewDelegate>
 
// return presenting view controller to display Ad contents modally, e.g. in internal WebBrowser
- (UIViewController *)presentingViewControllerForBannerView:(SMABannerView *)bannerView {
    return self;
}
 
// notification callback: ads TTL has expired
- (void)bannerViewDidTTLExpire:(SMABannerView *)bannerView {
    NSLog(@"Banner TTL has expired. You should load new one.");
}
...
@end


Swift code

// ViewController.swift
import UIKit
import SmaatoSDKBanner
 
class ViewController: UIViewController { 
    @IBOutlet weak var bannerView: SMABannerView!
     
    override func viewDidLoad() {
        super.viewDidLoad()
    }
}
 
extension ViewController: SMABannerViewDelegate {
   // return presenting view controller to display Ad contents modally, e.g. in internal WebBrowser
   func presentingViewController(for bannerView: SMABannerView) -> UIViewController {
        return self
   }
 
   // notification callback: ads TTL has expired
   func bannerViewDidTTLExpire(_ bannerView: SMABannerView) {
        print("Banner TTL has expired. You should load new one")
   }
}


5.)
In “viewDidLoad” of ViewController class, setup the BannerView:

Objective-C code

- (void)viewDidLoad {
    [super viewDidLoad];  
    self.bannerView.autoreloadInterval = kSMABannerAutoreloadIntervalVeryShort; // (optional) set the desired auto-reload time interval   
    self.bannerView.delegate = self;   // (required) set the delegate  
    [self.bannerView loadWithAdSpaceId:@"<SMAATO_ADSPACE_ID>"
                                adSize:kSMABannerAdSizeXXLarge_320x50]; // the desired size of the banner
}

Swift code

override func viewDidLoad() {
    super.viewDidLoad()
    bannerView.autoreloadInterval = .disabled   // (optional) set the desired auto-reload time interval    
    bannerView.delegate = self                  // (required) set the delegate    
    bannerView.load(withAdSpaceId: "<SMAATO_ADSPACE_ID>", 
                           adSize: .xxLarge_320x50)  // the desired size of the banner
}

6.) Build and run the app in the Simulator. The banner should then appear on your screen.

Steps to Integrate an Interstitial Ad

1.) Adopt your ViewController to SMAInterstitialDelegate protocol. Implement at least the required SMAInterstitialDelegate methods.

Objective-C code

// ViewController.m
#import "ViewController.h"
@import SmaatoSDKInterstitial;
 
// declare the ViewController to conform the SMAInterstitialDelegate protocol
@interface ViewController () <SMAInterstitialDelegate>
@property (nonatomic, strong) SMAInterstitial *interstitial;
@end
 
@implementation ViewController
 
...
// Interstitial did successfully loaded
- (void)interstitialDidLoad:(SMAInterstitial *)interstitial {
    self.interstitial = interstitial;
    [self.interstitial showFromViewController:self];
}
  
// Interstitial did fail loading
- (void)interstitial:(SMAInterstitial *)interstitial didFailWithError:(NSError *)error {
    NSLog(@"Interstitial did fail loading with error: %@", error.localizedDescription);
}
 
// Interstitial ads TTL has expired
- (void)interstitialDidTTLExpire:(SMAInterstitial *)interstitial {
    NSLog(@"Interstitial TTL has expired");
}
 
 
@end


Swift code

// ViewController.swift
import UIKit
import SmaatoSDKInterstitial
 
class ViewController: UIViewController {  
    private var interstitial: SMAInterstitial?
}
 
extension ViewController: SMAInterstitialDelegate {
    // Interstitial did successfully loaded
    func interstitialDidLoad(_ interstitialResponse: SMAInterstitial) {
        interstitial = interstitialResponse
        interstitialResponse.show(from: self)
    }
     
    // Interstitial did fail loading
    func interstitial(_ interstitial: SMAInterstitial?, didFailWithError error: Error) {
       print("Interstitial did fail loading with error: \(error.localizedDescription)")
    }
     
    // Interstitial ads TTL has expired    
    func interstitialDidTTLExpire(_ interstitial: SMAInterstitial) {
        print("Interstitial TTL has expired")
    }
}

2.) Create a method in ViewController class in order to load an interstitial and call it when you need to.

Objective-C code

- (void)callWhenYouNeedInterstitial {
    [SmaatoSDK loadInterstitialForAdSpaceId:@"<SMAATO_ADSPACE_ID>"
                                   delegate:self];
}

Swift code

func callWhenYouNeedInterstitial() {
    SmaatoSDK.loadInterstitial(forAdSpaceId: "<SMAATO_ADSPACE_ID>",                                                  
                                   delegate: self)
}

3.) Call your method, i.e. in “viewDidLoad” of ViewController class:

Objective-C code

- (void)viewDidLoad {
    [super viewDidLoad];
    [self callWhenYouNeedInterstitial];
}

Swift code

override func viewDidLoad() {
     super.viewDidLoad()
     callWhenYouNeedInterstitial()
}

 

4.) Lastly, build and run the app in the Simulator. The interstitial should then appear on the screen after loading.

Steps to Integrate a Rewarded Video Ad

1.) Adopt your ViewController to SMARewardedInterstitialDelegate protocol. Implement at least the required SMARewardedInterstitialDelegate methods.

Objective-C code

// ViewController.m
#import "ViewController.h"
@import SmaatoSDKRewardedAds;
 
// declare the ViewController to conform the SMARewardedInterstitialDelegate protocol
 
@interface ViewController () <SMARewardedInterstitialDelegate>
@property (nonatomic, strong) SMARewardedInterstitial *rewardedInterstitial;
@end
 
@implementation ViewController
...
// Rewarded Video did successfully loaded
- (void)rewardedInterstitialDidLoad:(SMARewardedInterstitial *)rewardedInterstitial {
    self.rewardedInterstitial = rewardedInterstitial;
    [rewardedInterstitial showFromViewController:self];
}
  
// Rewarded Video did fail loading
- (void)rewardedInterstitialDidFail:(SMARewardedInterstitial *)rewardedInterstitial withError:(NSError *)error {
    NSLog(@"Rewarded Video did fail loading with error: %@", error.localizedDescription);
}
 
// Rewarded Video TTL has expired
- (void)rewardedInterstitialDidTTLExpire:(SMARewardedInterstitial *)rewardedInterstitial {
    NSLog(@"Rewarded Video TTL has expired");
}
 
// Rewarded interstitial finishes the playing
- (void)rewardedInterstitialDidReward:(SMARewardedInterstitial *)rewardedInterstitial {
    NSLog(@"Rewarded Video finishes the playing");
}
 
@end


Swift code

// ViewController.swift
import UIKit
import SmaatoSDKRewardedAds
 
class ViewController: UIViewController {  
    private var rewardedInterstitial: SMARewardedInterstitial?
}
 
extension ViewController: SMARewardedInterstitialDelegate {
   ...
    // Rewarded Video did successfully loaded
    func rewardedInterstitialDidLoad(_ rewardedInterstitial: SMARewardedInterstitial) { 
        self.rewardedInterstitial = rewardedInterstitial
        rewardedInterstitial.show(from: self)
    }
     
    // Rewarded Video did fail loading    
    func rewardedInterstitialDidFail(_ rewardedInterstitial: SMARewardedInterstitial?, withError error: Error) {       
        print("Rewarded Video did fail loading with error: \(error.localizedDescription)")
    }
     
    // Rewarded Video TTL has expired    
    func rewardedInterstitialDidTTLExpire(_ rewardedInterstitial: SMARewardedInterstitial) {
        print("Rewarded Video TTL has expired")
    }
 
    // Rewarded interstitial finishes the playing    
    func rewardedInterstitialDidReward(_ rewardedInterstitial: SMARewardedInterstitial) {
        print("Rewarded Video finishes playing")
    }
}

 

2.) Create a method in ViewController class in order to load a Rewarded Video and call it when you need.

Objective-C code

- (void)callWhenYouNeedRewardedVideo {
    [SmaatoSDK loadRewardedInterstitialForAdSpaceId:@"<SMAATO_ADSPACE_ID>"
                                           delegate:self];
}

Swift code

func callWhenYouNeedRewardedVideo() {
    SmaatoSDK.loadRewardedInterstitial(forAdSpaceId: "<SMAATO_ADSPACE_ID>",
                                           delegate: self)
}

3.) Call your method, i.e. in “viewDidLoad” of ViewController class:

Objective-C code

- (void)viewDidLoad {
    [super viewDidLoad];
    [self callWhenYouNeedRewardedVideo];
}


Swift code

override func viewDidLoad() {
    super.viewDidLoad()
    callWhenYouNeedRewardedVideo()
}

 

4.) Lastly, build and run the app in the Simulator. The video should then appear on the screen.

Steps to integrate Key-value targeting

SMAKeyValuePairs is the public component that allows creating targeting parameters.

A new class property of SMAKeyValuePairs type, named keyValuePairs, is introduced for each ad type and allows publishers to pass the keywords to be included to the request.

Constraints of setting SMAKeyValuePairs:

  • Can be added up to 7 values per key. If one key contains more than 7 values, the SDK adds only 7 values to the query request.
  • Can be added up to 7 key-value pairs per request. If the dictionary contains more than 7 key-value pairs, the SDK adds only 7 key-value pairs to the query request.
  • Key is String type and Value is an Array of String type.

keyValuePairs is a class property and not a property on an instance of the class. This property can be set for Banners, Interstitials and Rewarded Videos.

SMAKeyValuePairs public header:

Objective-C code

@interface SMAKeyValuePairs : NSObject
 
// If aKey already exists in the dictionary, anObject is appended to the existing objects. Otherwise, key-value pair is added.
- (void)addTargetingValue:(NSString *_Nonnull)anObject forKey:(NSString *_Nonnull)aKey;
 
// If aKey already exists in the dictionary, anObject takes its place. Otherwise, key-value pair is added.
- (void)setTargetingValue:(NSString *_Nonnull)anObject forKey:(NSString *_Nonnull)aKey;
 
// If aKey already exists in the dictionary, anObject takes its place. Otherwise, key-value pair is added.
- (void)setTargetingValues:(NSArray<NSString *> *_Nonnull)anObject forKey:(NSString *_Nonnull)aKey;
 
// Empties the dictionary of its values.
- (void)removeAllKeyValuePairs;
 
// Removes specific key-value pair from the targeting.
- (void)removeKeyValuePairWithKey:(NSString *_Nonnull)aKey;
 
// Returns all key-value pairs that will be added to the query request.
- (NSDictionary *_Nullable)allKeyValuePairs;
 
@end

Banners

Since this property is class type, once it is set it will have the same value for all Banner instances because it belongs to the class itself. So, there will always be one copy of Type property that all instances can use.

  • Initialize a SMAKeyValuePairs object and set your targeting parameters by using the public interface.
  • Set the key-value pairs object to SMABannerView.keyValuePairs property.
  • Call load method on Banner to apply the key-values for that request.

Objective-C code

// ViewController.m 
#import "ViewController.h"
@import SmaatoSDKBanner;
   
@interface ViewController ()
   
// SMABannerView is linked in the Interface Builder with ViewController via IBOutlet.
@property (nonatomic) IBOutlet SMABannerView *bannerView;
@end
   
@implementation ViewController
   
- (void)viewDidLoad {
    [super viewDidLoad];
   
    // Let's create and set targeting parameters    
    SMAKeyValuePairs *KVP = [SMAKeyValuePairs new];
    [KVP setTargetingValue:@"30" forKey:@"Age"]; // replace with your key-value pairs configured on SPX site
    [KVP setTargetingValues:@[@"Demo", @"Stage"] forKey:@"Application"]; // replace with your key-value pairs configured on SPX site    
    SMABannerView.keyValuePairs = KVP;
   
    // Send request, after replacing with your 'AdSpaceID' configured on SPX site and the desired size of the banner
    [self.bannerView loadWithAdSpaceId:@"AdSpaceID" adSize:kSMABannerAdSizeXXLarge_320x50];
}
   
@end


Swift code

// ViewController.swift  
import Foundation
import SmaatoSDKBanner
   
class ViewController: UIViewController {
    // SMABannerView is linked in the Interface Builder with ViewController via IBOutlet.
 @IBOutlet var bannerView: SMABannerView?
    override func viewDidLoad() {
        super.viewDidLoad()
   
        // Let's create and set targeting parameters        
        let KVP = SMAKeyValuePairs()
        KVP.setTargetingValue("30", forKey: "Age") // replace with your key-value pairs configured on SPX site        
        KVP.setTargetingValues(["Demo", "Stage"], forKey: "Application") // replace with your key-value pairs configured on SPX site        
        SMABannerView.keyValuePairs = KVP
   
        // Send request, after replacing with your 'AdSpaceID' configured on SPX site.        
        self.bannerView?.load(withAdSpaceId: "AdSpaceID", adSize: .xxLarge_320x50)
    }
}

Interstitials

Since this property is class type, once it is set it will have the same value for all Interstitial requests because it belongs to the class itself. So, there will be always one copy of type property that all

Interstitial requests can use.

  • Initialize a SMAKeyValuePairs object and set your targeting parameters by using the public interface
  • Set the key-value pairs object to SMAInterstitial.keyValuePairs property
  • Call loadInterstitial method to apply the key-values for that request.

Objective-C code

// ViewController.m  
#import "ViewController.h"
@import SmaatoSDKInterstitial;
   
@interface ViewController () <SMAInterstitialDelegate>
@end
   
@implementation ViewController
   
- (void)viewDidLoad {
    [super viewDidLoad];
    [self callWhenYouNeedInterstitial];
}
   
- (void)callWhenYouNeedInterstitial {
    // Let's create and set targeting parameters    
    SMAKeyValuePairs *KVP = [SMAKeyValuePairs new];
    [KVP setTargetingValue:@"30" forKey:@"Age"]; // replace with your key-value pairs configured on SPX site       
    [KVP setTargetingValues:@[@"Demo", @"Stage"] forKey:@"Application"]; // replace with your key-value pairs configured on SPX site
    SMAInterstitial.keyValuePairs = KVP;
 
    // Send request, after replacing with your 'AdSpaceID' configured on SPX site.
    [SmaatoSDK loadInterstitialForAdSpaceId:@"AdSpaceID" delegate:self];
}
   
@end


Swift code

// ViewController.swift  
import Foundation
import SmaatoSDKInterstitial
   
class ViewController: UIViewController {
   
    override func viewDidLoad() {
        super.viewDidLoad()
        callWhenYouNeedInterstitial()
    }
   
    func callWhenYouNeedInterstitial() {
        // Let's create and set targeting parameters        
        let KVP = SMAKeyValuePairs()
        KVP.setTargetingValue("30", forKey: "Age") // replace with your key-value pairs configured on SPX site        
        KVP.setTargetingValues(["Demo", "Stage"], forKey: "Application") // replace with your key-value pairs configured on SPX site        
        SMAInterstitial.keyValuePairs = KVP
   
        // Send request, after replacing with your 'AdSpaceID' configured on SPX site.        
        SmaatoSDK.loadInterstitial(forAdSpaceId: "AdSpaceID", delegate: self)
    }
}

Rewarded Videos

Since this property is class type, once it is set it will have the same value for all Rewarded Video requests because it belongs to the class itself. So, there will be always one copy of Type property that all video requests can use.

  • Initialize a SMAKeyValuePairs object and set your targeting parameters by using the public interface
  • Set the key-value pairs object to SMAInterstitial.keyValuePairs property
  • Call loadRewardedInterstitial method to apply the key-values for that request.

Objective-C code

// ViewController.m  
#import "ViewController.h"
@import SmaatoSDKRewardedAds;
   
@interface ViewController () <SMARewardedInterstitialDelegate>
@end
   
@implementation ViewController
   
- (void)viewDidLoad {
    [super viewDidLoad];
    [self callWhenYouNeedRewardedAds];
}
   
- (void)callWhenYouNeedRewardedAds {
    // Let's create and set targeting parameters    
    SMAKeyValuePairs *KVP = [SMAKeyValuePairs new];
    [KVP setTargetingValue:@"30" forKey:@"Age"]; // replace with your key-value pairs configured on SPX site    
    [KVP setTargetingValues:@[@"Demo", @"Stage"] forKey:@"Application"]; // replace with your key-value pairs configured on SPX site
    SMARewardedInterstitial.keyValuePairs = KVP;
   
    // Send request, after replacing with your 'AdSpaceID' configured on SPX site.    
    [SmaatoSDK loadRewardedInterstitialForAdSpaceId:@"AdSpaceID" delegate:self];
}
   
@end

Swift code

// ViewController.swift 
import Foundation
import SmaatoSDKRewardedAds
   
class ViewController: UIViewController {
   
    override func viewDidLoad() {
        super.viewDidLoad()
        callWhenYouNeedRewardedAds()
    }
   
    func callWhenYouNeedRewardedAds() {
        // Let's create and set targeting parameters        
        let KVP = SMAKeyValuePairs()
        KVP.setTargetingValue("30", forKey: "Age") // replace with your key-value pairs configured on SPX site        
        KVP.setTargetingValues(["Demo", "Stage"], forKey: "Application") // replace with your key-value pairs configured on SPX site        
        SMARewardedInterstitial.keyValuePairs = KVP
   
        // Send request, after replacing with your 'AdSpaceID' configured on SPX site.        
        SmaatoSDK.loadRewardedInterstitial(forAdSpaceId: "AdSpaceID", delegate: self)
    }
}

 

 

Modified: November 8, 2019 at 5:08 pm