文档

支持

LevelPlay SDK - iOS

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:
pod 'IronSourceSDK','9.4.0.0'
If you are not using Swift in your project, go to Project > Build Settings > Linking > Runpath Search Paths and add the following code:
// needs to be first on the list /usr/lib/swift
注意
Starting with version 8.9.0, Ad Quality is integrated into the LevelPlay SDK and is automatically initialized when LevelPlay is implemented. For more information, refer to Ad Quality overview.

Swift Package Manager

注意
To use Swift Package Manager, you must have the minimum supported LevelPlay SDK version 9.3.0 and the corresponding adapter version defined in the Minimum adapter and network SDK versions section.
To add a package dependency to your project, complete the following steps:
  1. In Xcode, go to File > Add Package Dependencies.
  2. In the prompt that displays, search for the following package URL:
    https://github.com/ironsource-mobile/Unity-Mediation-iAds-Swift-Package
  3. In the Dependency Rule, select Branch.
  4. In the text field, enter
    main
    .

Minimum adapter and network SDK versions

Network name

Minimum adapter version

Minimum network SDK version

AppLovin5.6.013.6.2
BidMachine5.4.03.6.1
Meta5.2.06.21.1
Digital Turbine5.7.08.4.6
Google AdMob5.7.013.2.0
HyprMX5.3.06.4.6
LY Ad Network5.4.03.0.1
Mintegral5.10.08.1.0
MobileFuse5.2.01.11.0
MyTarget5.6.05.41.0
Ogury5.3.05.2.1
Pangle5.19.07.9.1.1
Voodoo5.0.03.15.1

Manual download

To manually add the LevelPlay SDK to your project, complete the following steps:
  1. Download iOS SDK version 9.4.0.
  2. Unzip the SDK and add
    IronSource.framework
    to your Xcode project.
  3. Add the following linker flag to the build settings at: Target > Build Settings > Linking > Other Linker Flags: -ObjC
  4. Import libraries - "z","sqlite3.0"
  5. 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 Application

Update 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). 
  1. In the Xcode Project navigator, select Info.plist.
  2. Select Add (+) next to a key in the property list editor and then select Return.
  3. Enter the key name SKAdNetworkItems.
  4. In the Type column, select Array.
  5. Create a dictionary item, and then create a single string item.
  6. Enter the key name SKAdNetworkIdentifier and the following key value:
    su67r6k2v3.skadnetwork
You can also add SKAdNetworkIdentifier to your Info.plist file by using this code: 
<key>SKAdNetworkItems</key><array> <dict> <key>SKAdNetworkIdentifier</key> <string>su67r6k2v3.skadnetwork</string> </dict></array>
For more information on editing the property list, refer to the Xcode documentation.

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.
  1. In the Xcode Project navigator, select Info.plist.
  2. Select Add (+) next to a key in the property list editor and then select Return.
  3. Enter the key name NSAdvertisingAttributionReportEndpoint.
  4. In the Type column, select String.
  5. Enter the following URL: 
    https://postbacks-is.com/
    .
For more information about Universal SKAN reporting, refer to Add SKAdNetwork IDs manually.

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
    NSAppTransportSecurity
    by selecting the plus symbol. Ensure that you add this dictionary to the Top Level Key.
    • Inside this dictionary, add a Boolean called
      NSAllowsArbitraryLoads
      and set it to
      YES
      by selecting the tab.
  • Ensure that your Info.plist file does not contain any other exceptions aside from
    NSAllowsArbitraryLoads
    because this might create a conflict.
  • 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:
  1. Define the completion handler success and failure.
  2. Call the LevelPlay init API by using the appKey and user ID, if relevant.
Add the user ID as part of the initialization request builder if you’re using server-to-server callbacks (to reward your users) or using the Ad Quality user journey.
// 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"];
After mediation init is complete, launch the test suite by calling the following method:
[LevelPlay launchTestSuite:self];

Next steps

  1. Refer to the following integration guides to implement ad formats:
  2. Integrate Rewarded Video, Interstitial or Banner Ads in your app. Refer to Mediation networks for iOS.