Import and Initialize SDK

Last Updated on: 22 Sep, 2023

BEFORE YOU START

  • Supported iOS version 10 and above.
  • Supported Xcode version 13.2.1 and above.

The download and use of the SDK are 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.

MESON MEDIATION DEMO APP

You can download the Integration Demo application for a better understanding. It demonstrates how you can integrate Meson Mediation into your app.

Add Meson SDK to 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 'MesonSDK' , '1.0.0-beta10'

Manual

Download Meson Prime SDK

After downloading, unzip it and add MesonSDK.xcframework to your Xcode Project.

Add Mediated SDK and Adapter

CocoaPods

To add the mediated SDK adapter and SDK with CocoaPods, select the networks and add the following dependencies to the pod file. For more information on the supported networks and integration, see Network Guides.

 

 

If you are on the Amazon network, see Integrate Amazon SDK for more information.

Use the following command to update the repository:

pod install --repo-update


Manual

To download the mediated SDKs and the supported adapter, click the link provided for each network. For more information on the supported networks and integration, see Network Guides.

Network Bid Type Formats  
Facebook Audience Network
Real-time CPM
Banner, Interstitial, MREC, Rewarded
Adapter | SDK
Vungle
Real-time CPM
Banner, Interstitial, MREC, Rewarded
Adapter | SDK
InMobi Audience Bidding
Real-time CPM
Banner, Interstitial, MREC, Rewarded, Native (iOS)
Adapter | SDK
Mintegral
Real-time CPM
Banner, Interstitial, MREC, Rewarded
Adapter | SDK
Unity
Predicted CPM
Banner, Interstitial, MREC, Rewarded
Adapter | SDK
Applovin
Predicted CPM
Banner, Interstitial, MREC, Rewarded
Adapter | SDK
IronSource
Fixed CPM
Interstitial, Rewarded
Adapter | SDK
Google Admob
Fixed CPM
Banner, Interstitial, MREC, Rewarded, Native
Adapter | SDK
Google Ad Manager
Fixed CPM
Banner, Interstitial, MREC, Rewarded, Native
Adapter | SDK
AdColony Advanced Bidding
Real-time CPM
Banner, Interstitial, MREC, Rewarded
Adapter | SDK

Add Frameworks

In Xcode, go to build phases, select Link Binary With Libraries, click the + icon and link the following frameworks in your project:

  • AdSupport
  • AppTrackingTransparency
  • AudioToolbox
  • AVFoundation
  • CoreGraphics
  • CoreMedia
  • CoreMotion
  • CoreTelephony
  • Foundation
  • MessageU
  • Ilibz
  • SafariServices
  • StoreKit
  • SystemConfiguration
  • UIKit
  • WebKit
  • MobileCoreServices

Integrating Apps in Objective C

Add the following linker flags to the build settings at, Target > Build Settings > Linking > Other Linker Flags: -ObjC

Important Prerequisites

App Transport Security (ATS)

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

<key>NSAppTransportSecurity</key> 
<dict>      
        <key>NSAllowsArbitraryLoads</key>     
        <true> 
</true></dict>

INFO

Ensure that your info.plist does not contain exceptions besides 'NSAllowsArbitraryLoad', as this might create a conflict. For more information on ATS, see NSAppTransportSecurity.

iOS 12 WiFi Settings

Apple has introduced privacy settings to access WiFi details from iOS 12 onwards. To boost monetization and relevant user experience, we encourage sharing WiFi details for targeted advertising.

  1. Enable ‘Access WiFi Information’ on your App ID.

  2. Enable ‘Access WiFi Information’ for your target app from XCode capabilities.

  3. Ensure WiFi Access is added to your App.entitlements file.

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.

Initialize the SDK once per app lifecycle using the MesonSdkConfiguration object.

MesonSdkConfiguration

Swift

import UIKit 
import MesonSDK 
 
@main 
class AppDelegate: UIResponder, UIApplicationDelegate { 

    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { 
        // Override point for customization after application launch.          
        // Setting Log level 
        Meson.setLogLevel(.debug) 

        initializeMesonSDK() 
       
        return true 
    } 

    private func initializeMesonSDK() { 

        let gdprConsent = [MesonConstant.MESON_GDPR_CONSENT_GDPR_APPLIES : "0", 
                           MesonConstant.MESON_GDPR_CONSENT_AVAILABLE : "true", 
                           MesonConstant.MESON_GDPR_CONSENT_IAB : "<iab or="" string="" v1="" v2="">"] 
         
#warning("Please enter you appId") 
        let config = MesonSdkConfiguration(appId: "appId", consent: gdprConsent) 
        Meson.initialize(sdkConfiguration: config) { error in 
            if let error = error as NSError?, let initializeError = MesonInitializationError.init(rawValue: error.code) { 
                print("MesonSDK initialization error \(initializeError)") 
            } 
            print("Meson\(Meson.getSDKVersion()) SDK initialized successfully") 
        } 
    } 

}</iab>

Objective-C

#import "AppDelegate.h" 
@import MesonSDK; 
 
@interface AppDelegate ()  
@end 
  

@implementation AppDelegate 
 

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { 
    // Override point for customization after application launch. 
    
    // Setting Log level 
    [Meson setLogLevel:LogLevelDebug]; 

    [self initializeMesonSDK]; 
     
    return YES; 
} 

  
- (void)initializeMesonSDK { 
    NSDictionary *gdprConsent = @{MesonConstant.MESON_GDPR_CONSENT_GDPR_APPLIES: @"0", 
                                MesonConstant.MESON_GDPR_CONSENT_AVAILABLE: @"true", 
                                MesonConstant.MESON_GDPR_CONSENT_IAB: @"IAB String v1 or v2" }; 

 
     #warning("Please enter you appId") 
    MesonSdkConfiguration *sdkConfiguration = [[MesonSdkConfiguration alloc] initWithAppId:@"appId" consent:gdprConsent]; 

 
     void (^completionBlock)(NSError*) = ^( NSError* _Nullable  error) { 
        if (error) { 
            NSLog(@"MesonSDK initialization error %@", error.description); 
        } else { 
            NSLog(@"Meson %@ SDK initialized successfully",[Meson getSDKVersion]); 
        } 
    }; 

  
    [Meson initializeWithSdkConfiguration:sdkConfiguration completion:completionBlock]; 
} 
@end

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

// Setting Log level 
Meson.setLogLevel(.debug)

Objective-C

// Setting Log level 
[Meson setLogLevel:LogLevelDebug];