Skip to main content

Import and Initialize SDK

Before you start

Meson supports iOS version 10 and above.

The download and use of the SDK is subject to the Meson SDK Licensing Terms. If you do not agree to these terms, do not download, access, or use the SDK, or the underlying services.

Add Meson SDK to the project#

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

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 'MesonSDK', '1.0.0-beta2'

Add Mediated SDK and Adaptor#

To add the mediated SDK adaptor and SDK with CocoaPods, select the networks and add the following dependencies to the pod file.

See the list of supported networks and integration guides here.

Facebook Audience Network
Real-time CPM
Real-time CPM
Real-time CPM
Real-time CPM
Predicted CPM
Predicted CPM
Fixed CPM
Google AdMob
Fixed CPM
Google Ad Manager
Fixed CPM

Integrating 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 on the 'Top Level Key'
  • Inside this dictionary, add a Boolean called 'NSAllowsArbitraryLoads' and set it to YES

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 by calling Meson.initialize(MesonSDKConfiguration configuration) method. The SDK must be initialized successfully before carrying out any other operations.

During initialization, the SDK will:

  • Fetch the mobile app configurations from the server
  • Set the GDPR consent settings for the given app
  • Initialize mediated SDKs

Initialize the SDK once per app lifecycle using the MesonSdkConfiguration object. The listener object is optional.

let gdprConsent = [MesonConstant.MESON_GDPR_CONSENT_GDPR_APPLIES : "0",
MesonConstant.MESON_GDPR_CONSENT_IAB : "<IAB String v1 or v2>" ]
//Initialize Meson SDK
Meson.initialize(sdkConfiguration: MesonSdkConfiguration(appId: "<APP_ID>", consent: gdprConsent)) { error in
if (error != nil) {
print("\(String(describing: error))")
} else {
print("SDK initialize successfully")

Add User Data#

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

To set user data, follow:

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

To get or reset user data, follow:

Meson.getExtras() //gets the extra values set in SetExtras
Meson.getSDKVersion() //gets the SDK version
//Clears Extras, location

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.