Skip to main content

iOS SDK Integration

Before you start

Meson supports iOS version 10 and above.

Supported Version of GAM: 8.3.0

Supported Version of MoPub: 5.1.7

For older versions please refer to SDK Changelog.

The download, use and access to the SDK is 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 the your 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 'MesonWrapSDK', '1.0.0'

Add the Plugins for GAM or MoPub#

Select the mediation platform:

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

pod 'MesonWrapGAM', '1.0.1'

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 on 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:

//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.initSDK(appId: "<#AppId>", gdpr: gdprConsentDictionary, completion: completionBlock)

Add User Data#

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

func setDemongForMeson() {
MesonWrap.setAge(age: 24)
MesonWrap.setYearOfBirth(yearOfBirth: "<YearOfBirth>")
MesonWrap.setCountry(country: "<country>")
MesonWrap.setCity(city: "<city>")
MesonWrap.setState(state: "<state>")
MesonWrap.setGender(gender: Gender.female)
MesonWrap.setAreaCode(areacode: "<areacode>")
MesonWrap.setPostalCode(postalCode: "postalCode>")
MesonWrap.setEducation(education: Education.collegeOrGraduate)
MesonWrap.setLanguage(langugage: "<langugage>")
MesonWrap.setInterset(interest: "<interest>")
MesonWrap.setAgeGroup(ageGroup: .between18And24)
MesonWrap.setKeyword(keyword: "<keyword>")
}
var locationMgr: CLLocationManager?
//Using CLLocationManagerDelegate fetch the coordinate
func setLocationForMeson() {
locationMgr = CLLocationManager()
locationMgr?.requestWhenInUseAuthorization()
locationMgr?.delegate = self
locationMgr?.startUpdatingLocation()
}
func locationManager(_ manager: CLLocationManager, didUpdateLocations locations: [CLLocation]) {
if let clLocation = locations.last {
MesonWrap.setLocation(location: clLocation)
}
locationMgr?.stopUpdatingLocation()
}

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.

MesonWrap.setLogLevel(level: .debug)
What Next?

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