Back to top

iOS SDK Integration

Last Updated on: 14 Jul, 2022

BEFORE YOU START

  • Meson supports iOS version 10 and above.
  • Supported Version of GAM: 9.5.0
  • For older versions please refer to SDK Changelog.
  • The download, use, and access to the SDK are subject to the Meson SDK Licensing Terms. If you do not agree to the terms of Meson Publisher Online Terms & Conditions, do not download, access, or use the SDK, or the underlying services.

Add the Meson SDK to your project

Meson supports both Cocoapods and manual download mechanisms to integrate our SDK.

CocoaPods

CocoaPods is a dependency manager for Objective-C and Swift; it automates and simplifies the SDK integration process. See the CocoaPods Guide on Getting Started and Using CocoaPods for more information.

To integrate the Meson SDK with CocoaPods, enter the following in your podfile:

pod 'MesonWrapSDK', '2.0.0'

Manual

Download WRAP SDK 2.0.0

After download, unzip it and add MesonWrapSDK.xcframework into your Xcode Project.

Add the Plugins for GAM

CocoaPods

To add GAM plugins with Cocoapods, enter the following in your podfile:

pod 'MesonWrapGAM', '2.0.0'

Manual

Download GAM Plugin 1.0.1.

After download, unzip it and add MesonWrapGAM.xcframework into your Xcode Project.

Integrating with Apps in Objective C

If your project is in Objective C:

  • Add an empty swift file in the project to fetch all the swift-related system settings. For more information please follow this article here.
  • Add the following linker flags to the build settings at, Target > Build Settings > Linking > Other Linker Flags: -ObjC.

Update the Property List File

To ensure uninterrupted support for ad delivery across all SDK-less Networks / Demand Partners, it's important to make the following changes in your info.plist:

  • Add in dictionary called 'NSAppTransportSecurity'. Make sure you add this dictionary to the 'Top-Level Key'
  • Inside this dictionary, add a Boolean called 'NSAllowsArbitraryLoads' and set it to YES

INFO

Make sure that your info.plist does not contain any other exceptions besides 'NSAllowsArbitraryLoad', as this might create a conflict. Find more information on ATS here.

Initialize the SDK

Initialize the SDK as follows:

Swift

//Import the MesonWrapSDK
import MesonWrapSDK

let completionBlock: ((Error?) -> Void)? = { error in
  if let error = error as Error? {
    print(error.localizedDescription)
    return
  } else {
    print("MesonWrap SDK initialised successfully")
  }
}
let gdprConsentDictionary : [String: Any] = ["gdpr": "0", "gdpr_consent" : "<IABString>"]
MesonWrap.initialize(appId: "<#AppId>", gdpr: gdprConsentDictionary, completion: completionBlock)

Objective-C

//Import the MesonWrapSDK;
@import MesonWrapSDK;

void (^completionBlock)(NSError*) = ^( NSError* _Nullable  error) {
  if (error) {
    NSLog(@"%@", error.description);
  }
  else {
    NSLog(@"MesonWrap SDK initialised successfully");
  }
};
NSDictionary *gdprConsentDictionary = @{@"gdpr": @"0", @"gdpr_consent" : @"<IABString>"};
[MesonWrap initSDKWithAppId:@"<#AppId>" gdpr: gdprConsentDictionary  completion:completionBlock];

Restricted Data Processing

To help publishers comply with the California Consumer Privacy Act (CCPA), the Meson SDK allows publishers to use either of the following parameters to enable restricted data processing (RDP). The parameter can be set at an ad request level utilizing the following parameters:

rdp: Set this to 1 for signaling restricted data processing.

us_privacy: Follow the IAB specification for signaling restricted data processing.

Swift

// You can notify Meson that restricted data processing is enabled using either of the following parameters.
let extras = [
  "rdp": false,
  "iab_usprivacy_string": "1YNN"
  ] as [String : Any]

Meson.setExtras(extras)

Objective-C

// You can notify Meson that restricted data processing is enabled using either of the following parameters.
NSDictionary *extras = @{
  @"rdp": @(FALSE),
  @"iab_usprivacy_string": @("1YNN"),
};

[Meson setExtras:extras];

Add User Data

This is optional. In case you want to send us any information about the user, please do as follows:

Swift

To set user data, follow:

//Set Extras
let extras =  [
  "age": age,
  "gender": Gender.Male.rawValue,
  "interests":"<interests>",
  "language": "<language>",
  "customIds": [ ["idtype":"PPID", "value": "adada134412y1876dad"],
  ["idtype":"IDL", "value": "mpqdan134412y1876dad"]],
  "segments": ["s1","s2","s3"],
  "experiments": ["e1","e2","e3"]] as [String : Any]

Meson.setExtras(extras)

//Set Location
Meson.setLocation(<CLLocation>)

Objective-C

NSDictionary *extras = @{
  @"age": @(18),
  @"gender": @(GenderMale),
  @"interests":@"<interests>",
  @"language": @"<language>",
  @"customIds": @[ @{@"idtype":@"IMEI", @"value": @"adada134412y1876dad"},
  @{@"idtype":@"CAID", @"value": @"mpqdan134412y1876dad"}],
  @"segments": @[@"s1",@"s2",@"s3"],
  @"experiments": @[@"e1",@"e2",@"e3"]};

[Meson setExtras:extras];

//Set Location
[Meson setLocation:<#CLLocation>];

To get or reset user data, follow:

Swift

//Getters
Meson.getExtras() //gets the extra values set in SetExtras
Meson.getSDKVersion() //gets the SDK version

//Clears Extras, location
Meson.clearUserInfo()

Objective-C

//Getters
[Meson getSDKVersion];
[Meson getExtras];

//Clears extras, location
[Meson cleanUserInfo];

Configure Logging

When logging is set to DEBUG, SDK will print key logs to the console that provide useful information about the initialization and bid request lifecycle.

Swift

MesonWrap.setLogLevel(level: .debug)

Objective-C

[MesonWrap setLogLevelWithLevel:LogLevelDebug];

WHAT'S NEXT

Next, let's integrate Banner/Interstitial ad units.