Skip to content
This repository has been archived by the owner on Feb 26, 2022. It is now read-only.

Added parameter 'userId' for server-to-server rewarded video callbacks. #42

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -85,15 +85,16 @@ class AppodealFlutterPlugin : FlutterPlugin, MethodCallHandler, ActivityAware {
val adTypes = args["adTypes"] as List<Int>
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) }
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)
}

Expand Down
4 changes: 3 additions & 1 deletion example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,9 @@ class _MyAppState extends State<MyApp> {
await Appodeal.initialize(
hasConsent: true,
adTypes: [AdType.banner, AdType.mrec, AdType.interstitial, AdType.reward, AdType.nonSkippable],
testMode: true);
testMode: true,
userId: 'User#123', // For S2S rewarded video callbacks
);

setState(() => isAppodealInitialized = true);
});
Expand Down
3 changes: 2 additions & 1 deletion lib/src/appodeal.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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<void> initialize(
{required bool hasConsent, List<int> adTypes = const [], bool testMode = false, bool verbose = false}) async {
{required bool hasConsent, List<int> 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
Expand All @@ -44,6 +44,7 @@ class Appodeal {
'adTypes': adTypes,
'testMode': testMode,
'verbose': verbose,
'userId' : userId,
});
}

Expand Down