文档

支持

LevelPlay SDK - Unity

Migrate to LevelPlay Init API

Transition to the LevelPlay initialization APIs to support the new Ad Unit APIs, starting from SDK version 8.4.0 and required in SDK version 9.0.0+.
阅读时间1 分钟最后更新于 1 天前

This guide explains how to initialize LevelPlay when transitioning to the new Ad Unit APIs.

Prerequisites

The minimum supported SDK is 8.4.0. You can download the latest SDK by installing the latest Ads Mediation package in Unity Package Manager, by upgrading from the Network Manager, or following instructions here.

Initialize the SDK

To initialize the LevelPlay SDK, follow these steps:
  1. Remove the callbacks and ad formats that previously referenced the legacy IronSource APIs.
  2. Implement callbacks for initialization success and failure.
  3. Call the LevelPlay init API using the appKey and user ID if relevant.
  4. Create Banner, Interstitial, and Rewarded ad objects.
Please refer to the following initalization sample:
using com.unity.services.levelplay;// Init the SDK when implementing the Ad Unit APIs for Banner, Interstitial, and Rewarded ad formats. LevelPlay.OnInitSuccess += SdkInitializationCompletedEvent;LevelPlay.OnInitFailed += SdkInitializationFailedEvent;LevelPlay.Init("YOUR_APPKEY", "UserId");

LevelPlay Init Listeners

OnInitSuccess
– triggered when the initialization is completed successfully. After you receive this indication, you can create and load the ad.
OnInitFailed
– the configuration was not retrieved successfully and ads cannot be loaded. It is recommended to try and initialize the LevelPlay SDK later (when internet connection is available, or when the failure reason is resolved).

Legacy

Ad Unit (new)

ClassIronSourceLevelPlay
APIinitInit
APIsetUserIDShould be set as part of the Init
CallbacksonInitializationCompleteOnInitSuccess
-OnInitFailed

LevelPlay Demo Scene/Sample App

The Unity Demo Scene/Sample application demonstrates how to integrate the Ad Unit APIs in your app. In the Unity Package Manager package details view, go to Samples and import the LevelPlay Sample. You can now implement the new Ad Unit APIs.