Flutter Plug-in integration
Integrate the LevelPlay SDK into your Flutter application to enable ad mediation and monetization across Android and iOS platforms.
阅读时间4 分钟最后更新于 6 天前
Prerequisites
- Flutter plug-in is supported from SDK version 7.2.1.2 for Android & iOS.
- Support Flutter 3.0.0+
Add the LevelPlay Mediation plug-in to your project
Pub.dev Integration
There are 2 options of adding the LevelPlay Flutter plug-in to your project, using the pub.dev interface.-
Run the Flutter CLI command
flutter pub get unity_levelplay_mediation
-
Update pubspec.yaml file by adding the definition to your pubspec.yaml file.
unity_levelplay_mediationdependencies:flutter: sdk: flutterunity_levelplay_mediation: '>=9.0.0 <9.1.0' - Add Ad Quality SDK
dependencies { implementation 'com.unity3d.ads-mediation:adquality-sdk:9.3.1'}
Manual Integration
Download Flutter Plug-in VersionLevelPlay demo app
The Integration Demo application demonstrates how to integrate ironSource LevelPlay in your app Download Flutter Demo ApplicationAdditional settings for iOS
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).- 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.
- In the Type column of the dialog, select Array.
- Create a dictionary item and corresponding single sting item.
-
Enter Key name SKAdNetworkIdentifier, and the key value:
You can also addsu67r6k2v3.skadnetworkto your Info.plist with the following code:SKAdNetworkIdentifier
Use ironSource SKAdNetwork IDs Manager to create code snippet to support ironSource network and mediated network IDs. For more information on editing the property list, see the Xcode documentation.<key>SKAdNetworkItems</key><array> <dict> <key>SKAdNetworkIdentifier</key> <string>su67r6k2v3.skadnetwork</string> </dict></array>
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.- 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 NSAdvertisingAttributionReportEndpoint
- Choose String from the pop-up menu in the Type column
- Type the URL:
https://postbacks-is.com/
App transport security settings
To ensure uninterrupted support for ad delivery across all mediation networks, it's important to make the following changes in yourinfo.plist- Add in a dictionary called . Make sure you add this dictionary on the Top Level Key.
NSAppTransportSecurity - Inside this dictionary, add a Boolean called and set it to YES.
NSAllowsArbitraryLoads - Make sure that your info.plist doesn't contain any other exceptions besides , as this might create a conflict.
NSAllowsArbitraryLoads - Find more information on ATS in the Apple documentation.
Additional setup for Android
Play Services Dependencies
Add Play Services Dependencies to your app level build.gradle as follows:dependencies { implementation 'com.google.android.gms:play-services-ads-identifier:18.2.0' implementation 'com.google.android.gms:play-services-appset:16.1.0'}
Android 12 Support
Apps updating their target API level to 31 (Android 12) will need to declare a Google Play services normal permission in the manifest file as follows:Read more about Google Advertising ID changes here.<uses-permission android:name="com.google.android.gms.permission.AD_ID"/>
Replace Label on AndroidManifest.xml
To prevent the label-related error on AndroidManifest, do the following:- Add ‘xmls:tools’ to AndroidManifest.xml of your project
- Add ‘tools:replace=”android:label”’ to the ‘application’ tag
Initialize LevelPlay SDK
To initialize the LevelPlay SDK, follow these steps:LevelPlay SDK 8.6.0 and later
- Implement callbacks for initialization success and failure.
- Define the list of ad formats to initialize in the session.
-
Create an init request using . The builder receives the following parameters:
LevelPlayInitRequest.builder- Your appkey (mandatory)
- User ID (optional, if required for your app)
- Call LevelPlay.init and pass the context and init request.
class MyLevelPlayInitListener implements LevelPlayInitListener { @override void onInitFailed(LevelPlayInitError error) { // Provided when init is failed } @override void onInitSuccess(LevelPlayConfiguration configuration) { // Provided when init is successfully executed }}LevelPlayInitRequest initRequest = LevelPlayInitRequest.builder([APP_KEY]) .build();LevelPlay.init(initRequest, MyLevelPlayInitListener());
LevelPlay SDK before 8.6.0
- Implement callbacks for initialization success and failure.
- Define the list of ad formats that require support from legacy LevelPlay API. This should include REWARDED.
- Call the LevelPlay.init API using the appKey, ad formats, and user ID if relevant.
class MyLevelPlayInitListener implements LevelPlayInitListener { @override void onInitFailed(LevelPlayInitError error) { // Provided when init is failed } @override void onInitSuccess(LevelPlayConfiguration configuration) { // Provided when init is successfully executed }}// Init the SDK when implementing the Multiple Ad Units Interstitial and Banner APIs, and Rewarded using legacy APIs List<AdFormat> legacyAdFormats = [AdFormat.REWARDED];LevelPlayInitRequest initRequest = LevelPlayInitRequest.builder([APP_KEY]) .withLegacyAdFormats(legacyAdFormats) .withUserId("userId") .build();LevelPlay.init(initRequest, MyLevelPlayInitListener());
LevelPlay Init Listeners
- : Triggered when the init completes successfully, and ads can be loaded.
onInitSuccess - : The configuration wasn't received successfully, and ads can't be loaded. The recommended best practice is to try and init the LevelPlay SDK later.
onInitFailed
- All APIs called before the init API were not changed and should have remained as is, in terms of functionality and syntax. This includes advanced settings, regulations settings or other APIs related to specific ad format
- If initialization fails, you can try and initialize the SDK again. Only after a successful initialization process will you be able to load ads.
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:After mediation init is completed successfully, launch the test suite by calling the following method (Application Context is required):LevelPlay.setMetaData({'is_test_suite': ['enable']});
For more details and an implementation example of the LevelPlay integration test suite navigate to this article.LevelPlay.launchTestSuite();
Adapters Debug
Call the following API to enable debug logs of mediated network adapters & SDKs:LevelPlay.setAdaptersDebug(true);
For Proguard Users Only
If you are using ProGuard with the ironSource SDK, you must add the following code to your ProGuard file (Android Studio: proguard-rules.pro or Eclipse: proguard-project.txt):-keepclassmembers class com.ironsource.sdk.controller.IronSourceWebView$JSInterface { public *;}-keepclassmembers class * implements android.os.Parcelable { public static final android.os.Parcelable$Creator *;}-keep public class com.google.android.gms.ads.** { public *;}-keep class com.ironsource.adapters.** { *;}-keep class com.ironsource.unity.androidbridge.** { *;}-dontwarn com.ironsource.mediationsdk.**-dontwarn com.ironsource.adapters.**-keepattributes JavascriptInterface-keepclassmembers class * { @android.webkit.JavascriptInterface <methods>;}
Next steps
- Follow our integration guides to implement ad formats
- Integrate our Rewarded Video, Interstitial or Banner Ads in your app and follow our Mediation articles.
- Verify your integration with our Integration Test Suite.