From 8a36fa7af13aed726b56acf4082aa4460b29fce9 Mon Sep 17 00:00:00 2001 From: AaaBbb Date: Sun, 17 Oct 2021 21:10:50 +0300 Subject: [PATCH 1/6] Added the ability to set user ID for server-to-server (S2S) rewarded video callbacks. --- .../io/vinicius/appodeal_flutter/AppodealFlutterPlugin.kt | 4 +++- example/lib/main.dart | 2 +- lib/src/appodeal.dart | 3 ++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/android/src/main/kotlin/io/vinicius/appodeal_flutter/AppodealFlutterPlugin.kt b/android/src/main/kotlin/io/vinicius/appodeal_flutter/AppodealFlutterPlugin.kt index 29b0fbd..9da265a 100644 --- a/android/src/main/kotlin/io/vinicius/appodeal_flutter/AppodealFlutterPlugin.kt +++ b/android/src/main/kotlin/io/vinicius/appodeal_flutter/AppodealFlutterPlugin.kt @@ -85,15 +85,17 @@ class AppodealFlutterPlugin : FlutterPlugin, MethodCallHandler, ActivityAware { val adTypes = args["adTypes"] as List val testMode = args["testMode"] as Boolean val verbose = args["verbose"] as Boolean + val userId = args["userId"] as String // Registering callbacks setCallbacks() val ads = adTypes.fold(0) { acc, value -> acc or getAdType(value) } + println("set user id = " + userId) + if (userId != "") Appodeal.getUserSettings(activity).setUserId(userId) Appodeal.setTesting(testMode) Appodeal.initialize(activity, appKey, ads, hasConsent) if (verbose) Appodeal.setLogLevel(Log.LogLevel.verbose) - result.success(null) } diff --git a/example/lib/main.dart b/example/lib/main.dart index 098ac4f..9c1c7f6 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -43,7 +43,7 @@ class _MyAppState extends State { await Appodeal.initialize( hasConsent: true, adTypes: [AdType.banner, AdType.mrec, AdType.interstitial, AdType.reward, AdType.nonSkippable], - testMode: true); + testMode: true, userId: '123'); setState(() => isAppodealInitialized = true); }); diff --git a/lib/src/appodeal.dart b/lib/src/appodeal.dart index 7ef7f2b..943b2c4 100644 --- a/lib/src/appodeal.dart +++ b/lib/src/appodeal.dart @@ -31,7 +31,7 @@ class Appodeal { /// also if ads should be presented in test mode [testMode] or not. Always set test mode as `true` during development /// or tests. static Future initialize( - {required bool hasConsent, List adTypes = const [], bool testMode = false, bool verbose = false}) async { + {required bool hasConsent, List adTypes = const [], bool testMode = false, bool verbose = false, String userId = ''}) async { assert(_androidAppKey != null || _iosAppKey != null, 'You must set at least one of the keys for Android or iOS'); // Register the callbacks @@ -44,6 +44,7 @@ class Appodeal { 'adTypes': adTypes, 'testMode': testMode, 'verbose': verbose, + 'userId' : userId, }); } From 4435aefe9ba02aec899bff8039a189f3f5d3e753 Mon Sep 17 00:00:00 2001 From: AaaBbb Date: Wed, 20 Oct 2021 21:12:43 +0300 Subject: [PATCH 2/6] ... --- example/lib/main.dart | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/example/lib/main.dart b/example/lib/main.dart index 9c1c7f6..793c003 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -43,7 +43,9 @@ class _MyAppState extends State { await Appodeal.initialize( hasConsent: true, adTypes: [AdType.banner, AdType.mrec, AdType.interstitial, AdType.reward, AdType.nonSkippable], - testMode: true, userId: '123'); + testMode: true, + userId: 'User#123' // For server-to-server (S2S) rewarded video callbacks + ); setState(() => isAppodealInitialized = true); }); From 55b4847a5c7db055b5b0a9a9f8d50f506076c62a Mon Sep 17 00:00:00 2001 From: AaaBbb Date: Wed, 20 Oct 2021 21:17:07 +0300 Subject: [PATCH 3/6] /// --- example/lib/main.dart | 44 ++++++++++++++++++++++++++++++------------- 1 file changed, 31 insertions(+), 13 deletions(-) diff --git a/example/lib/main.dart b/example/lib/main.dart index 793c003..9e79cf6 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -41,11 +41,17 @@ class _MyAppState extends State { // Initialize Appodeal after the authorization was granted or not await Appodeal.initialize( - hasConsent: true, - adTypes: [AdType.banner, AdType.mrec, AdType.interstitial, AdType.reward, AdType.nonSkippable], - testMode: true, - userId: 'User#123' // For server-to-server (S2S) rewarded video callbacks - ); + hasConsent: true, + adTypes: [ + AdType.banner, + AdType.mrec, + AdType.interstitial, + AdType.reward, + AdType.nonSkippable + ], + testMode: true, + userId: 'User#123', // For S2S rewarded video callbacks + ); setState(() => isAppodealInitialized = true); }); @@ -59,7 +65,9 @@ class _MyAppState extends State { title: const Text('Appodeal Example App'), ), body: isAppodealInitialized - ? SafeArea(child: SingleChildScrollView(child: IntrinsicWidth(child: _Body()))) + ? SafeArea( + child: SingleChildScrollView( + child: IntrinsicWidth(child: _Body()))) : Container()), ); } @@ -78,7 +86,8 @@ class _Body extends StatelessWidget { onPressed: () async { var shouldShow = await Appodeal.shouldShowConsent(); Fluttertoast.showToast( - msg: 'The app should${shouldShow ? ' ' : ' NOT '}collect user consent', + msg: + 'The app should${shouldShow ? ' ' : ' NOT '}collect user consent', toastLength: Toast.LENGTH_LONG, gravity: ToastGravity.BOTTOM); }, @@ -104,7 +113,9 @@ class _Body extends StatelessWidget { onPressed: () async { var isReady = await Appodeal.isReadyForShow(AdType.interstitial); Fluttertoast.showToast( - msg: isReady ? 'Interstitial ad is ready' : 'Interstitial ad is NOT ready', + msg: isReady + ? 'Interstitial ad is ready' + : 'Interstitial ad is NOT ready', toastLength: Toast.LENGTH_LONG, gravity: ToastGravity.BOTTOM); }, @@ -118,7 +129,8 @@ class _Body extends StatelessWidget { ElevatedButton( child: const Text('Show Interstitial Ad'), onPressed: () async { - await Appodeal.show(AdType.interstitial, placementName: "placement-name"); + await Appodeal.show(AdType.interstitial, + placementName: "placement-name"); }, ), ElevatedButton( @@ -134,7 +146,8 @@ class _Body extends StatelessWidget { ElevatedButton( child: const Text('Show Reward Ad'), onPressed: () async { - var status = await Appodeal.show(AdType.reward, placementName: 'placement-name'); + var status = await Appodeal.show(AdType.reward, + placementName: 'placement-name'); Fimber.i("$status"); }, ), @@ -143,7 +156,9 @@ class _Body extends StatelessWidget { onPressed: () async { var isReady = await Appodeal.isReadyForShow(AdType.nonSkippable); Fluttertoast.showToast( - msg: isReady ? 'Non-Skippable ad is ready' : 'No-Skippable ad is NOT ready', + msg: isReady + ? 'Non-Skippable ad is ready' + : 'No-Skippable ad is NOT ready', toastLength: Toast.LENGTH_LONG, gravity: ToastGravity.BOTTOM); }, @@ -151,9 +166,12 @@ class _Body extends StatelessWidget { ElevatedButton( child: const Text('Can Show Non-Skippable Ad?'), onPressed: () async { - var canShow = await Appodeal.canShow(AdType.nonSkippable, placementName: "placement-name"); + var canShow = await Appodeal.canShow(AdType.nonSkippable, + placementName: "placement-name"); Fluttertoast.showToast( - msg: canShow ? 'Non-Skippable can be shown' : 'Non-Skippable can NOT be shown', + msg: canShow + ? 'Non-Skippable can be shown' + : 'Non-Skippable can NOT be shown', toastLength: Toast.LENGTH_LONG, gravity: ToastGravity.BOTTOM); }, From 5f2fe8b80accf873b20e1433abd4c1abb8c9aa58 Mon Sep 17 00:00:00 2001 From: AaaBbb Date: Wed, 20 Oct 2021 21:18:39 +0300 Subject: [PATCH 4/6] 111 --- example/lib/main.dart | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/example/lib/main.dart b/example/lib/main.dart index 9e79cf6..92c646d 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -42,13 +42,7 @@ class _MyAppState extends State { // Initialize Appodeal after the authorization was granted or not await Appodeal.initialize( hasConsent: true, - adTypes: [ - AdType.banner, - AdType.mrec, - AdType.interstitial, - AdType.reward, - AdType.nonSkippable - ], + adTypes: [AdType.banner, AdType.mrec, AdType.interstitial, AdType.reward, AdType.nonSkippable], testMode: true, userId: 'User#123', // For S2S rewarded video callbacks ); From 6f6bbaab4826a4028865d2238ccccad2965b64cf Mon Sep 17 00:00:00 2001 From: AaaBbb Date: Wed, 20 Oct 2021 21:30:32 +0300 Subject: [PATCH 5/6] =?UTF-8?q?=D1=8E=D1=8E=D1=8E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- example/lib/main.dart | 38 +++++++++++++------------------------- 1 file changed, 13 insertions(+), 25 deletions(-) diff --git a/example/lib/main.dart b/example/lib/main.dart index 92c646d..81407c1 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -41,11 +41,11 @@ class _MyAppState extends State { // Initialize Appodeal after the authorization was granted or not await Appodeal.initialize( - hasConsent: true, - adTypes: [AdType.banner, AdType.mrec, AdType.interstitial, AdType.reward, AdType.nonSkippable], - testMode: true, - userId: 'User#123', // For S2S rewarded video callbacks - ); + hasConsent: true, + adTypes: [AdType.banner, AdType.mrec, AdType.interstitial, AdType.reward, AdType.nonSkippable], + testMode: true, + userId: 'User#123', // For S2S rewarded video callbacks + ); setState(() => isAppodealInitialized = true); }); @@ -59,9 +59,7 @@ class _MyAppState extends State { title: const Text('Appodeal Example App'), ), body: isAppodealInitialized - ? SafeArea( - child: SingleChildScrollView( - child: IntrinsicWidth(child: _Body()))) + ? SafeArea(child: SingleChildScrollView(child: IntrinsicWidth(child: _Body()))) : Container()), ); } @@ -80,8 +78,7 @@ class _Body extends StatelessWidget { onPressed: () async { var shouldShow = await Appodeal.shouldShowConsent(); Fluttertoast.showToast( - msg: - 'The app should${shouldShow ? ' ' : ' NOT '}collect user consent', + msg: 'The app should${shouldShow ? ' ' : ' NOT '}collect user consent', toastLength: Toast.LENGTH_LONG, gravity: ToastGravity.BOTTOM); }, @@ -107,9 +104,7 @@ class _Body extends StatelessWidget { onPressed: () async { var isReady = await Appodeal.isReadyForShow(AdType.interstitial); Fluttertoast.showToast( - msg: isReady - ? 'Interstitial ad is ready' - : 'Interstitial ad is NOT ready', + msg: isReady ? 'Interstitial ad is ready' : 'Interstitial ad is NOT ready', toastLength: Toast.LENGTH_LONG, gravity: ToastGravity.BOTTOM); }, @@ -123,8 +118,7 @@ class _Body extends StatelessWidget { ElevatedButton( child: const Text('Show Interstitial Ad'), onPressed: () async { - await Appodeal.show(AdType.interstitial, - placementName: "placement-name"); + await Appodeal.show(AdType.interstitial, placementName: "placement-name"); }, ), ElevatedButton( @@ -140,8 +134,7 @@ class _Body extends StatelessWidget { ElevatedButton( child: const Text('Show Reward Ad'), onPressed: () async { - var status = await Appodeal.show(AdType.reward, - placementName: 'placement-name'); + var status = await Appodeal.show(AdType.reward, placementName: 'placement-name'); Fimber.i("$status"); }, ), @@ -150,9 +143,7 @@ class _Body extends StatelessWidget { onPressed: () async { var isReady = await Appodeal.isReadyForShow(AdType.nonSkippable); Fluttertoast.showToast( - msg: isReady - ? 'Non-Skippable ad is ready' - : 'No-Skippable ad is NOT ready', + msg: isReady ? 'Non-Skippable ad is ready' : 'No-Skippable ad is NOT ready', toastLength: Toast.LENGTH_LONG, gravity: ToastGravity.BOTTOM); }, @@ -160,12 +151,9 @@ class _Body extends StatelessWidget { ElevatedButton( child: const Text('Can Show Non-Skippable Ad?'), onPressed: () async { - var canShow = await Appodeal.canShow(AdType.nonSkippable, - placementName: "placement-name"); + var canShow = await Appodeal.canShow(AdType.nonSkippable, placementName: "placement-name"); Fluttertoast.showToast( - msg: canShow - ? 'Non-Skippable can be shown' - : 'Non-Skippable can NOT be shown', + msg: canShow ? 'Non-Skippable can be shown' : 'Non-Skippable can NOT be shown', toastLength: Toast.LENGTH_LONG, gravity: ToastGravity.BOTTOM); }, From aaf7f97596429aad3b3d04e637d51d3343619490 Mon Sep 17 00:00:00 2001 From: AaaBbb Date: Wed, 20 Oct 2021 21:33:22 +0300 Subject: [PATCH 6/6] Added parameter 'userId' for server-to-server rewarded video callbacks. --- .../kotlin/io/vinicius/appodeal_flutter/AppodealFlutterPlugin.kt | 1 - 1 file changed, 1 deletion(-) diff --git a/android/src/main/kotlin/io/vinicius/appodeal_flutter/AppodealFlutterPlugin.kt b/android/src/main/kotlin/io/vinicius/appodeal_flutter/AppodealFlutterPlugin.kt index 9da265a..d7c9eb4 100644 --- a/android/src/main/kotlin/io/vinicius/appodeal_flutter/AppodealFlutterPlugin.kt +++ b/android/src/main/kotlin/io/vinicius/appodeal_flutter/AppodealFlutterPlugin.kt @@ -91,7 +91,6 @@ class AppodealFlutterPlugin : FlutterPlugin, MethodCallHandler, ActivityAware { setCallbacks() val ads = adTypes.fold(0) { acc, value -> acc or getAdType(value) } - println("set user id = " + userId) if (userId != "") Appodeal.getUserSettings(activity).setUserId(userId) Appodeal.setTesting(testMode) Appodeal.initialize(activity, appKey, ads, hasConsent)