Getting Started with the ironSource iOS SDK

Before You Start
We support iOS versions 7+.

Step 1. Add the SDK to Your Project

ironSource 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','6.6.7.1'

Manual Download

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

  1. Add IronSource Framework
    After you download the SDK; unzip it and add IronSource.framework into your Xcode Project.
  2. Add Linker Flags
    Add the following linker flag to the build settings at:
    Target ➣ Build Settings ➣ Linking ➣ Other Linker Flags:
    ObjC

 

App Transport Security Settings


Important! In iOS 9, Apple added in controls around ‘ATS’. 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‘. Make sure you add this dictionary on the ‘Top Level Key‘.
  •  Inside this dictionary, add a Boolean called ‘NSAllowsArbitraryLoads‘ and set it to YES.ats
     Note:

    • Make sure that your info.plist does not contain any other exceptions besides ‘NSAllowsArbitraryLoads‘, as this might create a conflict.
    • Find more information on ATS here.

Step 2. Set The Delegates

  1. Import the following file:
    OBJECTIVE-C

    #import "IronSource/IronSource.h"

    SWIFT
    Download the IronSource-Bridging-Head.h. Then, go to Targets Build Settings ➣ Objective-C Bridging Header and add the path to your bridging header file. Find detailed instructions and download the header file here.

  2.  Optional: To receive detailed log events, you can register to the log delegate.

    OBJECTIVE-C

    [IronSource setLogDelegate:YOUR_LOG_DELEGATE];

    SWIFT

    IronSource.setLogDelegate(myLogDelegate)
  3. Set Delegates

    The ironSource SDK fires several events to inform you of your ad unit activity. To receive these events, register to the delegates of the ad units you set up on the ironSource platform.

    • For Rewarded Video
      OBJECTIVE-C

      [IronSource setRewardedVideoDelegate:yourRewardedVideoDelegate];

      SWIFT

      IronSource.setRewardedVideoDelegate(yourRewardedVideoDelegate)
    • For Interstitial
      OBJECTIVE-C

      [IronSource setInterstitialDelegate:yourInterstitialDelegate];

      SWIFT

      IronSource.setInterstitialDelegate(yourInterstitialDelegate)
    • For Offerwall
      OBJECTIVE-C

      [IronSource setOfferwallDelegate:yourOfferwallDelegate];

      SWIFT

      IronSource.setOfferwallDelegate(yourOfferwallDelegate)
      

Step 3. Initialize the ironSource SDK

ironSource supports optional SDK settings such as UserID and Segments that must be configured before you initialize the SDK. See our guide on Additional SDK Settings for setup instructions.

Note: If you’re serving the Offerwall ad unit or using server-to-server callbacks to reward your users with our rewarded ad units, you must set the UserID.

Init the SDK

You can initialize the SDK in two ways. We recommend the first method as it will fetch the specific ad units you define. Ad unit is a string array.

  1. This method will init the specific ad units mentioned in the adUnits parameter:
    OBJECTIVE-C

    [IronSource initWithAppkey:YOUR_APP_KEY adUnits:YOUR_AD_UNITS];

    SWIFT

    IronSource.initWithAppkey(kAPPKEY, adUnits:YOUR_AD_UNITS)

    Sample:

    OBJECTIVE-C

    [IronSource initWithAppKey:APP_KEY adUnits:@[IS_REWARDED_VIDEO]];
    /** or for all ad units
    [IronSource initWithAppKey:APP_KEY adUnits:@[IS_REWARDED_VIDEO,IS_INTERSTITIAL,IS_OFFERWALL, IS_BANNER]];

    SWIFT

    IronSource.initWithAppKey(kAPPKEY, adUnits:[IS_REWARDED_VIDEO];
    /** or for all ad units
    IronSource.initWithAppKey(kAPPKEY, adUnits:[IS_REWARDED_VIDEO,IS_INTERSTITIAL,IS_OFFERWALL, IS_BANNER];

2.  Alternatively, you can init the SDK as detailed below and the SDK will init the ad units you’ve  configured on the ironSource platform:
OBJECTIVE-C

[IronSource initWithAppkey:YOUR_APP_KEY];

SWIFT

IronSource.initWithAppKey(kAPPKEY)

Step 4. Verify Your Integration

The ironSource SDK provides an easy way to verify that your SDK and Mediation integration was completed successfully. To verify your ironSource SDK integration as well as any additional ad networks you have implemented, simply add this method to your project:

OBJECTIVE-C

[ISIntegrationHelper validateIntegration];

SWIFT

ISIntegrationHelper.validateIntegration()

For more details on the ironSource Integration Verification tool navigate to this article.

 

Done! You just integrated the ironSource SDK in your app. 
You are now ready to start working with the ironSource Ad Units and advanced mediation platform.


What’s Next?

Once you’ve verified your integration with the Integration Helper, follow the integration guides and implement our Ad Units:

 

Interested in the ironSource Mediation platform? Integrate our Rewarded Video or Interstitial Ads and follow our Mediation articles.

You can read this article in: