iOS SDK integration
Integrate the LevelPlay SDK into your iOS app by using CocoaPods or manual methods, and initialize it with your app key.
阅读时间4 分钟最后更新于 1 天前
The LevelPlay SDK supports CocoaPods, Swift Package Manager, and manual download mechanisms to integrate the SDK.
Prerequisites
iOS version support is defined per network. ironSource ads and LevelPlay mediation support iOS versions 12+, and Xcode versions 15.4+. To be compatible with iOS 14, ironSource released SDK 7+ with support for SKAdNetwork attribution.Add the SDK to your project
CocoaPods
CocoaPods is a dependency manager for Objective-C and Swift; it automates and simplifies the SDK integration process. For more information, refer to the CocoaPods documentation on Getting Started and Using CocoaPods. To integrate the LevelPlay SDK with CocoaPods, enter the following line in your Podfile:If you are not using Swift in your project, go to Project > Build Settings > Linking > Runpath Search Paths and add the following code:pod 'IronSourceSDK','9.4.0.0'
// needs to be first on the list /usr/lib/swift
Swift Package Manager
To add a package dependency to your project, complete the following steps:
- In Xcode, go to File > Add Package Dependencies.
- In the prompt that displays, search for the following package URL:
https://github.com/ironsource-mobile/Unity-Mediation-iAds-Swift-Package - In the Dependency Rule, select Branch.
- In the text field, enter .
main
Minimum adapter and network SDK versions
Network name | Minimum adapter version | Minimum network SDK version |
|---|---|---|
| AppLovin | 5.6.0 | 13.6.2 |
| BidMachine | 5.4.0 | 3.6.1 |
| Meta | 5.2.0 | 6.21.1 |
| Digital Turbine | 5.7.0 | 8.4.6 |
| Google AdMob | 5.7.0 | 13.2.0 |
| HyprMX | 5.3.0 | 6.4.6 |
| LY Ad Network | 5.4.0 | 3.0.1 |
| Mintegral | 5.10.0 | 8.1.0 |
| MobileFuse | 5.2.0 | 1.11.0 |
| MyTarget | 5.6.0 | 5.41.0 |
| Ogury | 5.3.0 | 5.2.1 |
| Pangle | 5.19.0 | 7.9.1.1 |
| Voodoo | 5.0.0 | 3.15.1 |
Manual download
To manually add the LevelPlay SDK to your project, complete the following steps:- Download iOS SDK version 9.4.0.
- Unzip the SDK and add to your Xcode project.
IronSource.framework - Add the following linker flag to the build settings at: Target > Build Settings > Linking > Other Linker Flags: -ObjC
- Import libraries - "z","sqlite3.0"
- Import frameworks - "JavaScriptCore","WebKit","AdSupport","SystemConfiguration"
LevelPlay mediation demo app
The Integration demo application demonstrates how to integrate the LevelPlay Mediation in your app. Download iOS Demo ApplicationUpdate the property list file
SKAdNetwork support
To enable the display of ironSource network ads when using SDK 7+, ensure that you include the ironSource ad network ID in your app property list file (Info.plist).- In the Xcode Project navigator, select Info.plist.
- Select Add (+) next to a key in the property list editor and then select Return.
- Enter the key name SKAdNetworkItems.
- In the Type column, select Array.
- Create a dictionary item, and then create a single string item.
-
Enter the key name SKAdNetworkIdentifier and the following key value:
su67r6k2v3.skadnetwork
For more information on editing the property list, refer to the Xcode documentation.<key>SKAdNetworkItems</key><array> <dict> <key>SKAdNetworkIdentifier</key> <string>su67r6k2v3.skadnetwork</string> </dict></array>
Universal SKAN reporting
To receive copies of winning install-validation postbacks from all of the demand sources for your advertised app, add the NSAdvertisingAttributionReportEndpoint key in your app’s Info.plist file.- In the Xcode Project navigator, select Info.plist.
- Select Add (+) next to a key in the property list editor and then select Return.
- Enter the key name NSAdvertisingAttributionReportEndpoint.
- In the Type column, select String.
- Enter the following URL: .
https://postbacks-is.com/
App transport security settings
To ensure uninterrupted support for LevelPlay ad delivery across all mediation networks, make the following changes in your Info.plist file:- Add the dictionary by selecting the plus symbol. Ensure that you add this dictionary to the Top Level Key.
NSAppTransportSecurity- Inside this dictionary, add a Boolean called and set it to
NSAllowsArbitraryLoadsby selecting the tab.YES
- Inside this dictionary, add a Boolean called
- Ensure that your Info.plist file does not contain any other exceptions aside from because this might create a conflict.
NSAllowsArbitraryLoads - For more information about App transport security, refer to the Apple documentation.
Initialize the LevelPlay SDK
Import the necessary files
#import "IronSource/IronSource.h"
Init the SDK
To initialize the LevelPlay SDK, complete the following steps:- Define the completion handler success and failure.
- Call the LevelPlay init API by using the appKey and user ID, if relevant.
// Create a request builder with app key and ad formats. Add User ID if availableLPMInitRequestBuilder *requestBuilder = [[LPMInitRequestBuilder alloc] initWithAppKey:@"appKey"];[requestBuilder withUserId:@"UserId"];// Build the initial requestLPMInitRequest *initRequest = [requestBuilder build];// Initialize LevelPlay with the prepared request[LevelPlay initWithRequest:initRequest completion:^(LPMConfiguration *_Nullable config, NSError *_Nullable error){ if(error) { // There was an error on initialization. Take necessary actions or retry } else { // Initialization was successful. You can now create ad objects and load ads or perform other tasks }}];
Initialization result
- Success: Triggered when the initialization is completed successfully. After you receive this indication, you can create and load the ad.
- Error: The configuration was not retrieved successfully and ads cannot be loaded. The recommended best practice is to try and initialize the LevelPlay SDK later when an internet connection is available or when the failure reason is resolved.
Verify your integration
Use the LevelPlay integration test suite to test your app’s integration, verify platform setup, and review ads related to your configured networks. To enable the test suite in your app, call the setMetaData API before setting the init:[LevelPlay setMetaDataWithKey:@"is_test_suite" value:@"enable"];
[LevelPlay launchTestSuite:self];
Next steps
- Refer to the following integration guides to implement ad formats:
- Integrate Rewarded Video, Interstitial or Banner Ads in your app. Refer to Mediation networks for iOS.