Skip to content

Commit 6de3001

Browse files
author
GitHub Actions
committed
Release Flutter SDK 3.1.0
1 parent eecaa63 commit 6de3001

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+983
-402
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
## 3.1.0 , 2025
2+
3+
- Android SDK: 8.6.1
4+
- iOS SDK: 8.6.0
5+
16
## 3.0.1 , 2024
27

38
- Android SDK: 8.4.0

README.md

Lines changed: 96 additions & 99 deletions
Original file line numberDiff line numberDiff line change
@@ -93,47 +93,48 @@ Read more about Apple's ATT and user privacy guideline [here](https://developer.
9393

9494
### Implement Listeners
9595

96-
#### LevelPlayRewardedVideoListener
96+
#### LevelPlayRewardedAdListener
9797
```dart
98-
class LevelPlayRewardedVideoListenerClass with LevelPlayRewardedVideoListener {
98+
class LevelPlayRewardedAdVideoListenerClass with LevelPlayRewardedVideoListener {
9999
@override
100-
void onAdAvailable(IronSourceAdInfo? adInfo) {
101-
// Indicates that there's an available ad.
100+
void onAdLoaded(LevelPlayAdInfo adInfo) {
101+
// Provided when the ad is successfully loaded
102102
}
103103
104104
@override
105-
void onAdUnavailable() {
106-
// Indicates that no ads are available to be displayed
105+
void onAdLoadFailed(LevelPlayAdError error) {
106+
// Provided when the ad fails to load. Ad Unit information is included
107107
}
108108
109109
@override
110-
void onAdOpened(IronSourceAdInfo? adInfo) {
111-
// The Rewarded Video ad view has opened. Your activity will loose focus
110+
void onAdDisplayed(LevelPlayAdInfo adInfo) {
111+
// Provided when the ad is displayed. This is equivalent to an impression
112112
}
113-
113+
114114
@override
115-
void onAdClosed(IronSourceAdInfo? adInfo) {
116-
// The Rewarded Video ad view is about to be closed. Your activity will regain its focus
115+
void onAdDisplayFailed(LevelPlayAdError error, LevelPlayAdInfo adInfo) {
116+
// Provided when the ad fails to be displayed
117117
}
118118
119+
@override
120+
void onAdClicked(LevelPlayAdInfo adInfo) {
121+
// Provided when the user clicks on the ad
122+
}
119123
120124
@override
121-
void onAdRewarded(IronSourceRewardedVideoPlacement? placement, IronSourceAdInfo? adInfo) {
122-
// The user completed to watch the video, and should be rewarded.
123-
// The placement parameter will include the reward data.
124-
// When using server-to-server callbacks, you may ignore this event and wait for the ironSource server callback
125+
void onAdClosed(LevelPlayAdInfo adInfo) {
126+
// Provided when the ad is closed
125127
}
126128
127129
@override
128-
void onAdShowFailed(IronSourceError? error, IronSourceAdInfo? adInfo) {
129-
// The rewarded video ad was failed to show
130+
void onAdInfoChanged(LevelPlayAdInfo adInfo) {
131+
// Provided when the ad info is updated. Available when another ad has loaded, and includes a higher CPM/Rate
130132
}
131133
132134
@override
133-
void onAdClicked(IronSourceRewardedVideoPlacement? placement, IronSourceAdInfo? adInfo) {
134-
// Invoked when the video ad was clicked.
135-
// This callback is not supported by all networks, and we recommend using it
136-
// only if it's supported by all networks you included in your build
135+
void onAdRewarded(LevelPlayReward reward, LevelPlayAdInfo adInfo) {
136+
// The user completed to watch the video, and should be rewarded.
137+
// The reward parameter will include the reward data.
137138
}
138139
}
139140
```
@@ -253,9 +254,13 @@ class LevelPlayNativeAdListenerClass with LevelPlayNativeAdListener {
253254
```dart
254255
Future<void> init() async {
255256
final appKey = '[YOUR_APP_KEY]';
257+
final userId = '[YOUR_USER_ID]';
256258
try {
257259
List<AdFormat> legacyAdFormats = [AdFormat.BANNER, AdFormat.REWARDED, AdFormat.INTERSTITIAL, AdFormat.NATIVE_AD];
258-
final initRequest = LevelPlayInitRequest(appKey: appKey, legacyAdFormats: legacyAdFormats);
260+
final initRequest = LevelPlayInitRequest.builder(configState.appKey)
261+
.withLegacyAdFormats(legacyAdFormats)
262+
.withUserId(userId)
263+
.build();
259264
await LevelPlay.init(initRequest: initRequest, initListener: this);
260265
} on PlatformException catch (e) {
261266
print(e);
@@ -267,118 +272,110 @@ Future<void> init() async {
267272

268273
#### LevelPlayRewardedVideo
269274
```dart
270-
Future<void> _showRewardedVideoOnClick() async {
271-
if (await IronSource.isRewardedVideoAvailable()) {
272-
IronSource.showRewardedVideo();
275+
final LevelPlayRewardedAd _rewardedAd = LevelPlayRewardedAd(adUnitId: [YOUR_AD_UNIT]);
276+
277+
@override
278+
void initState() {
279+
super.initState();
280+
_rewardedAd.setListener([YOUR_LISTENER]);
281+
}
282+
283+
void _loadRewarded() {
284+
_rewardedAd.loadAd();
285+
}
286+
287+
Future<void> _showRewarded() async {
288+
if (await _rewardedAd.isAdReady()) {
289+
_rewardedAd.showAd(placement: [YOUR_PLACEMENT]);
273290
}
274291
}
292+
293+
// Rest of the class
275294
```
276295

277296
#### LevelPlayInterstitial
278297

279298
```dart
280-
LevelPlayInterstitialAd? _interstitialAd;
299+
final LevelPlayInterstitialAd _interstitialAd = LevelPlayInterstitialAd(adUnitId: [YOUR_AD_UNIT]);
281300
282301
@override
283302
void initState() {
284303
super.initState();
285-
_createInterstitialAd();
286-
}
287-
288-
void _createInterstitialAd() {
289-
_intersitialAd = LevelPlayInterstitialAd(adUnitId: [YOUR_AD_UNIT]);
290-
_interstitialAd!.setListener([YOUR_LISTENER]);
304+
_interstitialAd.setListener([YOUR_LISTENER]);
291305
}
292306
293307
void _loadInterstitial() {
294-
_interstitialAd?.loadAd();
308+
_interstitialAd.loadAd();
295309
}
296310
297311
Future<void> _showInterstitial() async {
298-
if (await __interstitialAd?.isAdReady()) {
299-
_interstitialAd?.showAd(placement: [YOUR_PLACEMENT]);
312+
if (await _interstitialAd.isAdReady()) {
313+
_interstitialAd.showAd(placement: [YOUR_PLACEMENT]);
300314
}
301315
}
316+
317+
// Rest of the class
302318
```
303319

304320
#### LevelPlayBanner
305321

306322
```dart
307-
LevelPlayBannerAdView? _bannerAdView;
308-
309-
@override
310-
void initState() {
311-
super.initState();
312-
_createBannerAdView();
323+
final _bannerKey = GlobalKey<LevelPlayBannerAdViewState>();
324+
final _adSize = LevelPlayAdSize.BANNER;
325+
final _adUnitId = 'YOUR_AD_UNIT_ID';
326+
final _placementName = 'YOUR_PLACEMENT';
327+
328+
void _loadAd() {
329+
_bannerKey.currentState?.loadAd();
330+
// or store LevelPlayBannerAdView in variable and call '_bannerAdView.loadAd();'
313331
}
314332
315-
void _createBannerAdView() {
316-
final _bannerkey = GlobalKey<LevelPlayBannerAdViewState>();
317-
_bannerAdView = LevelPlayBannerAdView(
333+
@override
334+
Widget build(BuildContext context) {
335+
return
336+
LevelPlayBannerAdView(
318337
key: _bannerKey,
319-
adUnitId: [YOUR_AD_UNIT_ID],
320-
adSize:[YOUR_AD_SIZE],
321-
listener: [YOUR_LISTENER],
322-
placementName: [YOUR_PLACEMENT],
323-
onPlatformViewCreated: _loadBanner
324-
);
325-
}
326-
327-
void _loadBanner() {
328-
_bannerAdView?.loadAd();
329-
// or store and use key - _bannerKey.currentState?.loadAd();
338+
adUnitId: _adUnitId,
339+
adSize: _adSize,
340+
listener: this,
341+
placementName: _placementName,
342+
onPlatformViewCreated: () {
343+
_loadAd();
344+
},
345+
);
330346
}
331347
```
332348

333349
#### LevelPlayNativeAd
334350
```dart
335-
class _LevelPlayNativeAdsSection extends State<LevelPlayNativeAdsSection> with LevelPlayNativeAdListener {
336-
LevelPlayNativeAd? _nativeAd;
337-
LevelPlayNativeAdView? _nativeAdView;
351+
LevelPlayNativeAd? _nativeAd;
338352
339-
@override
340-
void initState() {
341-
super.initState();
342-
_createNativeAd();
343-
_createNativeAdView();
344-
}
353+
@override
354+
void initState() {
355+
super.initState();
356+
_nativeAd = LevelPlayNativeAd.builder()
357+
.withPlacementName(_placementName)
358+
.withListener(this)
359+
.build();
360+
}
345361
346-
/// Initialize native ad object
347-
void _createNativeAd() {
348-
_nativeAd = LevelPlayNativeAd.builder()
349-
.withPlacementName('YOUR_PLACEMENT_NAME') // Your placement name string
350-
.withListener(LevelPlayNativeAdListenerClass()) // Your level play native ad listener
351-
.build();
352-
}
362+
/// Load native ad
363+
void _loadAd() {
364+
_nativeAd?.loadAd();
365+
}
353366
354-
/// Initialize native ad view widget with native ad
355-
void _createNativeAdView() {
356-
_nativeAdView = LevelPlayNativeAdView(
357-
key: GlobalKey(),
358-
// Unique key to force recreation of widget
359-
height: 150,
360-
// Your chosen height
361-
width: double.infinity,
362-
// Your chosen width
367+
@override
368+
Widget build(BuildContext context) {
369+
return
370+
LevelPlayNativeAdView(
371+
height: _height,
372+
width: _width,
363373
nativeAd: _nativeAd,
364-
// Native ad object
365-
templateType: LevelPlayTemplateType.SMALL,
366-
// Built-in native ad template(not required when implementing custom template)
367-
templateStyle: LevelPlayNativeAdTemplateStyle( // Level play native ad styling(optional)
368-
callToActionStyle: LevelPlayNativeAdElementStyle(
369-
backgroundColor: Colors.white,
370-
textColor: Colors.lightBlue
371-
)
372-
),
374+
templateType: _templateType,
375+
onPlatformViewCreated: () {
376+
_loadAd();
377+
},
373378
);
374-
}
375-
376-
/// Load native ad
377-
void _loadAd() {
378-
_nativeAd?.loadAd();
379-
}
380-
381-
// Rest of the class
382379
}
383380
```
384381

@@ -389,8 +386,8 @@ Note:
389386
- Make sure to read the official documents at [ironSource Knowledge Center](TODO: replace with the real KC link) for proper usage.
390387
- Some configurations must be done before initialization.
391388
- LevelPlayBannerListener is deprecated - Please use LevelPlayBannerAdViewListener with LevelPlayBannerAdView instead.
392-
393-
389+
- LevelPlayInterstitialListener is deprecated - Please use LevelPlayInterstitialAdListener with LevelPlayInterstitialAd instead.
390+
-
394391
# Mediation
395392

396393
- You can use the ironSource LevelPlay's mediation feature by adding adapters/SDKs to your project.

android/build.gradle

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ rootProject.allprojects {
1818
repositories {
1919
google()
2020
mavenCentral()
21-
maven { url 'https://android-sdk.is.com/' }
2221
}
2322
}
2423

@@ -39,5 +38,5 @@ android {
3938
dependencies {
4039
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
4140
// ironSource SDK
42-
implementation 'com.ironsource.sdk:mediationsdk:8.4.0'
41+
implementation 'com.unity3d.ads-mediation:mediation-sdk:8.6.1'
4342
}

android/src/main/kotlin/com/ironSource/ironsource_mediation/Extensions.kt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import com.unity3d.mediation.LevelPlayAdInfo
1414
import com.unity3d.mediation.LevelPlayAdSize
1515
import com.unity3d.mediation.LevelPlayConfiguration
1616
import com.unity3d.mediation.LevelPlayInitError
17+
import com.unity3d.mediation.rewarded.LevelPlayReward
1718
import java.io.ByteArrayOutputStream
1819

1920
/**
@@ -243,4 +244,11 @@ fun LevelPlayAdError.toMap(): HashMap<String, Any?> {
243244
"errorCode" to this.getErrorCode(),
244245
"errorMessage" to this.getErrorMessage()
245246
)
247+
}
248+
249+
fun LevelPlayReward.toMap(): HashMap<String, Any?> {
250+
return hashMapOf(
251+
"name" to this.name,
252+
"amount" to this.amount
253+
)
246254
}

android/src/main/kotlin/com/ironSource/ironsource_mediation/IronSourceMediationPlugin.kt

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import com.unity3d.mediation.LevelPlay
2424
import com.unity3d.mediation.LevelPlayAdSize
2525
import com.unity3d.mediation.LevelPlayInitRequest
2626
import com.unity3d.mediation.interstitial.LevelPlayInterstitialAd
27+
import com.unity3d.mediation.rewarded.LevelPlayRewardedAd
2728
import io.flutter.embedding.android.FlutterActivity
2829
import io.flutter.embedding.android.FlutterFragmentActivity
2930
import io.flutter.embedding.engine.FlutterEngine
@@ -207,6 +208,11 @@ class IronSourceMediationPlugin : FlutterPlugin, MethodCallHandler, ActivityAwar
207208
"disposeAllAds" -> disposeAllAds(result)
208209
/** LevelPlayAdSize API ===============================================================================*/
209210
"createAdaptiveAdSize" -> createAdaptiveAdSize(call, result)
211+
/** LevelPlayRewardedAd API ===============================================================================*/
212+
"isRewardedAdPlacementCapped" -> isRewardedAdPlacementCapped(call, result)
213+
"loadRewardedAd" -> loadRewardedAd(call, result)
214+
"showRewardedAd" -> showRewardedAd(call, result)
215+
"isRewardedAdReady" -> isRewardedAdReady(call, result)
210216
else -> result.notImplemented()
211217
}
212218
}
@@ -962,6 +968,35 @@ class IronSourceMediationPlugin : FlutterPlugin, MethodCallHandler, ActivityAwar
962968

963969
// endregion
964970

971+
/** region LevelPlayRewardedAd API =================================================================*/
972+
private fun isRewardedAdPlacementCapped(call: MethodCall, result: Result) {
973+
val placementName: String = call.argument("placementName")!!
974+
val isCapped = LevelPlayRewardedAd.isPlacementCapped(placementName)
975+
result.success(isCapped)
976+
}
977+
978+
private fun loadRewardedAd(call: MethodCall, result: Result) {
979+
val adObjectId: Int = call.argument("adObjectId")!!
980+
val adUnitId: String = call.argument("adUnitId")!!
981+
levelPlayAdObjectManager.loadRewardedAd(adObjectId, adUnitId)
982+
result.success(null)
983+
}
984+
985+
private fun showRewardedAd(call: MethodCall, result: Result) {
986+
val adObjectId: Int = call.argument("adObjectId")!!
987+
val placementName: String? = call.argument("placementName")
988+
levelPlayAdObjectManager.showRewardedAd(adObjectId, placementName)
989+
result.success(null)
990+
}
991+
992+
private fun isRewardedAdReady(call: MethodCall, result: Result) {
993+
val adObjectId: Int = call.argument("adObjectId")!!
994+
val isReady = levelPlayAdObjectManager.isRewardedAdReady(adObjectId)
995+
result.success(isReady)
996+
}
997+
998+
// endregion
999+
9651000
/** region ActivityAware =======================================================================*/
9661001
override fun onAttachedToActivity(binding: ActivityPluginBinding) {
9671002
activity = binding.activity

0 commit comments

Comments
 (0)