Unity Package Integration
Step 1. Add LevelPlay to your Unity project
You can install the LevelPlay package using two main methods:
- [Recommended] Add the Ads Mediation package to your project by navigating to Window -> Package Manager in Unity. Look for “Ads Mediation” and click the install button.
-
- You can also add the package by its name: com.unity.services.levelplay
-
- Or, Download Unity Plugin Version 8.10.0 (.unitypackage) and import it into your Unity project.
Once installed, the built-in sample allows you to explore & experiment with a working integration of LevelPlay. In the Package Manager’s package details view go to Samples, import the LevelPlay Sample and start digging!
Step 2. Initialize the SDK
If you haven’t done so already, go to the LevelPlay Platform and create a new app. Once done, use your App Key to initialize the SDK:
using com.unity3d.mediation;
LevelPlay.OnInitSuccess += SdkInitializationSuccessEvent;
LevelPlay.OnInitFailed += SdkInitializationFailedEvent;
LevelPlay.Init(“ThisIsYourAppKey”);
It is important to register OnInitFailed and OnInitSuccess before initializing LevelPlay as they provide you with important insight:
OnInitSuccess – triggered when LevelPlay initialized successfully. After you receive this callback, you can start showing ads in your app.
OnInitFailed – triggered when LevelPlay failed to initialize and therefore ads will not show. We recommend trying to initialize LevelPlay later (when internet connection is available, or when the failure reason is resolved).
You can pass in a User ID when initializing LevelPlay. This is useful if you’re trying to use Ad Quality’s User Journey, or if you’re using server-to-server callbacks to reward your users.
Step 3. LevelPlay Network Manager
The LevelPlay Network Manager window is a one stop shop for all things LevelPlay. You can find it in Unity’s top navigation bar, under Ads Mediation. From here, you can:
- Update your LevelPlay SDK.
- Install & update your preferred Ad Networks. Once installed, you’ll need to configure each ad network separately. Learn more.
- Get your app’s Info.plist automatically updated with SKAdNetwork IDs according to the ad networks you have installed.
Starting from LevelPlay Unity package 8.8.1, the Unity Ads adapter will be installed by default, in addition to ironSource Ads. For more information about setting up your Unity Ads account, see Unity Ads Integration Guide.
Android
To apply your changes and download the relevant ad network artifacts, you’ll need to use a resolver.
Go to: Assets → Mobile Dependency Manager → Android Resolver → Resolve
You should do this after each change in the LevelPlay Network Manager.
If you’re using Gradle, you can avoid downloading the network artifacts into your project. Instead, the artifacts will be added to your Gradle file during the compilation.
To enable this process, follow these steps (note: if you imported Mobile Dependency Resolver with Unity package 8.10.0 or later, this will be done automatically):
- Go to: Project Settings → Player → Android → Publishing Settings
- Enable Custom Main Gradle Template
- Go to: Assets → Mobile Dependency Manager → Android Resolver → Settings
- Select “Patch mainTemplate.gradle”
- Save your changes, by pressing “OK”
Step 4. Additional setup
iOS
SKAdNetwork support
LevelPlay can automatically manage this for you. Open the Network Manager to opt-in, as described in Step 3.
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).
- Select Info.plist in the Project navigator in Xcode
- Click the Add button (+) beside a key in the property list editor and press Return
- Type the key name SKAdNetworkItems
- Choose Array from the pop-up menu in the Type column
- Create a dictionary item, and below it a single string item
- 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.
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‘. Make sure you add this dictionary on the ‘Top Level Key‘.
- Inside this dictionary, add a Boolean called ‘NSAllowsArbitraryLoads‘ and set it to YES.
- 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.
Android
Apps using Android 13+ (API level 33+) will need to declare a Google Play services normal permission in the manifest file as follows:
<uses-permission android:name="com.google.android.gms.permission.AD_ID"/>
Read more about Google Advertising ID changes here.
Step 5. Verify your integration
The LevelPlay package provides an easy way to verify that your integration was completed successfully with its integration test suite. 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 following before initializing the SDK:
LevelPlay.SetMetaData("is_test_suite", "enable");
After successfully initializing LevelPlay, launch the test suite by calling the following method:
LevelPlay.LaunchTestSuite();
For more details and an implementation example of the LevelPlay integration test suite navigate to this article.
Done!
LevelPlay is now fully configured and ready to go. Below you’ll find additional guides to help you get started with setting up your Ad Units.
What’s Next?
Follow our integration guides to implement ad formats: