iOS SDK integration

Integrate the ironSource SDK into your iOS app using CocoaPods or manual methods, and initialize it with your app key and ad formats.

Read time 8 minutes

Prerequisites

iOS version support is defined per network. ironSource ads and LevelPlay mediation support iOS versions 13+, and Xcode versions 15.4+.

To be compatible with iOS 14, ironSource released SDK 7+ with support for SKAdNetwork attribution. You can learn more about updating to SDK 7 here.

Step 1. Add the SDK to Your Project

ironSource SDK 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 our SDK with Cocoapods, enter the following line in your podfile:

pod 'IronSourceSDK','8.9.1.0'

If you are not using swift in your project, go to Project > Build Settings > Linking > Runpath search path, and add the following code:

// needs to be first on the list 
/usr/lib/swift

Manual Download

Follow these steps to add the ironSource SDK to your project:

  1. Download iOs SDK Version 8.9.1 After you download the SDK; unzip the file and change IronSource.framework to IronSourceAdQualitySDK.xcframework
  2. Add the following linker flag to the build settings at: Target > Build Settings > Linking > Other Linker Flags: ObjC
  3. Import libraries - "z","sqlite3.0"
  4. Import frameworks -  "JavaScriptCore","WebKit","AdSupport","SystemConfiguration"

ironSource Mediation Demo App

The Integration Demo application demonstrate how to integrate Unity LevelPlay Mediation in your app.

[sdk_btn platform="ios" type="demo"]

Step 2. Update Property List file (Info.plist)

SKAdNetwork Support

To enable the display of ironSource network ads while using SDK 7+, make sure to include the ironSource ad network ID in your app property list file (Info.plist). 

  1. Select Info.plist in the Project navigator in Xcode

  2. Click the Add button (+) beside a key in the property list editor and press Return

  3. Type the key name SKAdNetworkItems

  4. Choose Array from the pop-up menu in the Type column

  5. Create a dictionary item, and below it a single string item  

  6. Enter Key name SKAdNetworkIdentifier, and the key value:

    su67r6k2v3.skadnetwork
    

You can also add SKAdNetworkIdentifier to your Info.plist, 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, see 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.

  1. Select Info.plist in the Project navigator in Xcode
  2. Click the Add button (+) beside a key in the property list editor and press Return
  3. Type the key name NSAdvertisingAttributionReportEndpoint
  4. Choose String from the pop-up menu in the Type column
  5. Type the URL: https://postbacks-is.com/

Learn more about Universal SKAN reporting here.

App Transport Security Settings

To ensure uninterrupted support for ironSource ad delivery across all mediation networks, it's important to make the following changes in your info.plist:

  • Add in a dictionary called ‘NSAppTransportSecurity‘ by pressing the plus symbol. Make sure you add this dictionary on the ‘Top Level Key‘.
  • Inside this dictionary, add a Boolean called ‘NSAllowsArbitraryLoads‘ and set it to YES by selecting the tab.

Note:

  • Ensure that your info.plist does not contain any other exceptions besides 'NSAllowsArbitraryLoads‘, as this might create a conflict.
  • Find more information on ATS at the Apple documentation.

Step 3. Set The Delegates

Import the necessary files

#import "IronSource/IronSource.h"

Download the IronSource.h file. Then, go to Targets > Build Settings > Objective-C Bridging Header and add the path to your bridging header file. For Swift, find detailed instructions and download the header file here.

Set Delegates

  • For Rewarded Video

Rewarded Video ad unit uses the Legacy ironSource SDK. To receive events which inform you of your ad unit activity, register to the delegates of the Rewarded Video ad unit you set up on the LevelPlay platform.

Ensure that you set the rewarded video delegates before initializing the SDK, to avoid any loss of information.

[IronSource setLevelPlayRewardedVideoDelegate:yourLevelPlayRewardedVideoDelegate];
IronSource.setLevelPlayRewardedVideoDelegate(yourLevelPlayRewardedVideoDelegate)
  • For Interstitial and Banner

Interstitial and Banner ad units use the LevelPlay Multiple Ad Unit SDK. Check their respective integration guides for ad delegates implementations.

Step 4. Initialize the ironSource SDK

Init the SDK

To initialize the ironSource SDK, follow these steps:

  1. Define the list of ad formats to initialize in the session. This should include REWARDED, as it's not officially supported for Multiple Ad Units API. 
  2. Call the LevelPlay init API using the appKey, ad formats, and user ID if relevant.
  3. Define the completion handler success and failure.

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 Ad Quality user journey.

    // Create a request builder with app key and ad formats. Add User ID if available
LPMInitRequestBuilder *requestBuilder = [[LPMInitRequestBuilder alloc] initWithAppKey:@"appKey"];
[requestBuilder withLegacyAdFormats:@[IS_REWARDED_VIDEO]];
[requestBuilder withUserId:@"UserId"];

// Build the initial request
LPMInitRequest *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         
   }
}];
// Create a request builder with app key and ad formats. Add User ID if available
let requestBuilder = LPMInitRequestBuilder(appKey: "appKey")
   .withLegacyAdFormats([IS_REWARDED_VIDEO])
   .withUserId("UserId")
// Build the initial request
let initRequest = requestBuilder.build()
// Initialize LevelPlay with the prepared request 
LevelPlay.initWith(initRequest) 
{ config, error in
if let error = 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. It is recommended to try and initialize the ironSource SDK later (when internet connection is available, or when the failure reason is resolved) 

Step 5. 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:

[IronSource setMetaDataWithKey:@"is_test_suite" value:@"enable"];

After mediation init is completed successfully, launch the test suite by calling the following method:

[IronSource launchTestSuite:self];

Next steps

  1. Follow our integration guides to implement ad formats
  2. Integrate our Rewarded Video, Interstitial or Banner Ads in your app and follow our Mediation articles.
  3. Verify your integration with our Integration Test Suite.