Skip to content

Commit 70ddc18

Browse files
authored
Releases/6.x.x/6.16.x/6.16.21 rc1 (#396)
* fixed Locale issue by forcing toUpperCase(Locale.ENGLISH) (#395) * Expanded the unit–tests to verify not only that the right native method is invoked, but also that the correct arguments are passed. * bumped constant for internal testing * pre release push prepare
1 parent 5ab2580 commit 70ddc18

File tree

6 files changed

+56
-17
lines changed

6 files changed

+56
-17
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
# Versions
2+
## 6.16.21
3+
- Bug fix for users who reported Locale issue on Android, fixed Locale issue by forcing toUpperCase(Locale.ENGLISH)
4+
- Expanded the unit–tests
25
## 6.16.2
36
- setConsentData is now deprecated!
47
- setConsentDataV2 is the new and recommended way to set manual user consent.

android/src/main/java/com/appsflyer/appsflyersdk/AppsflyerSdkPlugin.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
import java.util.HashMap;
3535
import java.util.Iterator;
3636
import java.util.List;
37+
import java.util.Locale;
3738
import java.util.Map;
3839

3940
import io.flutter.embedding.engine.plugins.FlutterPlugin;
@@ -1008,7 +1009,7 @@ private void logAdRevenue(MethodCall call, Result result) {
10081009
double revenue = requireNonNullArgument(call, "revenue");
10091010
String mediationNetworkString = requireNonNullArgument(call, "mediationNetwork");
10101011

1011-
MediationNetwork mediationNetwork = MediationNetwork.valueOf(mediationNetworkString.toUpperCase());
1012+
MediationNetwork mediationNetwork = MediationNetwork.valueOf(mediationNetworkString.toUpperCase(Locale.ENGLISH));
10121013

10131014
// No null check for additionalParameters since it's acceptable for it to be null (optional data)
10141015
Map<String, Object> additionalParameters = call.argument("additionalParameters");

example/lib/main_page.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ class MainPageState extends State<MainPage> {
169169

170170
AdRevenueData adRevenueData = AdRevenueData(
171171
monetizationNetwork: 'SpongeBob',
172-
mediationNetwork: AFMediationNetwork.googleAdMob.value,
172+
mediationNetwork: AFMediationNetwork.applovinMax.value,
173173
currencyIso4217Code: 'USD',
174174
revenue: 100.3,
175175
additionalParameters: customParams);

lib/src/appsflyer_constants.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ part of appsflyer_sdk;
33
enum EmailCryptType { EmailCryptTypeNone, EmailCryptTypeSHA256 }
44

55
class AppsflyerConstants {
6-
static const String PLUGIN_VERSION = "6.16.2";
6+
static const String PLUGIN_VERSION = "6.16.21";
77
static const String AF_DEV_KEY = "afDevKey";
88
static const String AF_APP_Id = "afAppId";
99
static const String AF_IS_DEBUG = "isDebug";

pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: appsflyer_sdk
22
description: A Flutter plugin for AppsFlyer SDK. Supports iOS and Android.
3-
version: 6.16.2
3+
version: 6.16.21
44

55
homepage: https://github.com/AppsFlyerSDK/flutter_appsflyer_sdk
66

test/appsflyer_sdk_test.dart

Lines changed: 48 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ void main() {
77

88
late AppsflyerSdk instance;
99
String selectedMethod = "";
10+
dynamic capturedArguments;
1011
const MethodChannel methodChannel = MethodChannel('af-api');
1112
const MethodChannel callbacksChannel = MethodChannel('callbacks');
1213
const EventChannel eventChannel = EventChannel('af-events');
@@ -63,6 +64,7 @@ void main() {
6364
case 'disableSKAdNetwork':
6465
case 'setDisableAdvertisingIdentifiers':
6566
selectedMethod = method;
67+
capturedArguments = methodCall.arguments;
6668
break;
6769
}
6870
return null;
@@ -73,9 +75,18 @@ void main() {
7375
String method = methodCall.method;
7476
if (method == 'listen') {
7577
selectedMethod = method;
78+
capturedArguments = methodCall.arguments;
7679
}
7780
return null;
7881
});
82+
83+
// Mock handler for callbacks channel to avoid MissingPluginException during startListening
84+
TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger
85+
.setMockMethodCallHandler(callbacksChannel, (methodCall) async {
86+
selectedMethod = methodCall.method;
87+
capturedArguments = methodCall.arguments;
88+
return null;
89+
});
7990
});
8091

8192
test('check initSdk call', () async {
@@ -90,11 +101,14 @@ void main() {
90101
group('AppsFlyerSdk', () {
91102
setUp(() {
92103
selectedMethod = "";
104+
capturedArguments = null;
93105
});
94106

95107
tearDown(() {
96108
TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger
97109
.setMockMethodCallHandler(methodChannel, null);
110+
TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger
111+
.setMockMethodCallHandler(callbacksChannel, null);
98112
});
99113

100114
test('check logEvent call', () async {
@@ -104,45 +118,56 @@ void main() {
104118
});
105119

106120
test('check setHost call', () async {
107-
instance.setHost("", "");
121+
instance.setHost("prefix", "hostname");
108122

109123
expect(selectedMethod, 'setHost');
124+
expect(capturedArguments['hostPrefix'], 'prefix');
125+
expect(capturedArguments['hostName'], 'hostname');
110126
});
111127

112128
test('check setCurrencyCode call', () async {
113-
instance.setCurrencyCode("currencyCode");
129+
instance.setCurrencyCode("USD");
114130

115131
expect(selectedMethod, 'setCurrencyCode');
132+
expect(capturedArguments['currencyCode'], 'USD');
116133
});
117134

118135
test('check setIsUpdate call', () async {
119136
instance.setIsUpdate(true);
120137

121138
expect(selectedMethod, 'setIsUpdate');
139+
expect(capturedArguments['isUpdate'], true);
122140
});
123141

124142
test('check stop call', () async {
125143
instance.stop(true);
126144

127145
expect(selectedMethod, 'stop');
146+
expect(capturedArguments['isStopped'], true);
128147
});
129148

130149
test('check updateServerUninstallToken call', () async {
131-
instance.updateServerUninstallToken("token");
150+
instance.updateServerUninstallToken("token123");
132151

133152
expect(selectedMethod, 'updateServerUninstallToken');
153+
expect(capturedArguments['token'], 'token123');
134154
});
135155

136156
test('check setOneLinkCustomDomain call', () async {
137157
instance.setOneLinkCustomDomain(["brandDomains"]);
138158

139159
expect(selectedMethod, 'setOneLinkCustomDomain');
160+
expect(capturedArguments, isA<List>());
161+
expect(capturedArguments, contains('brandDomains'));
140162
});
141163

142164
test('check logCrossPromotionAndOpenStore call', () async {
143-
instance.logCrossPromotionAndOpenStore("appId", "campaign", null);
165+
instance.logCrossPromotionAndOpenStore("appId123", "campaignA", null);
144166

145167
expect(selectedMethod, 'logCrossPromotionAndOpenStore');
168+
expect(capturedArguments['appId'], 'appId123');
169+
expect(capturedArguments['campaign'], 'campaignA');
170+
expect(capturedArguments['params'], null);
146171
});
147172

148173
test('check logCrossPromotionImpression call', () async {
@@ -177,9 +202,12 @@ void main() {
177202

178203
test('check validateAndLogInAppPurchase call', () async {
179204
instance.validateAndLogInAppAndroidPurchase(
180-
"publicKey", "signature", "purchaseData", "price", "currency", null);
205+
"publicKey", "signature", "purchaseData", "9.99", "EUR", null);
181206

182207
expect(selectedMethod, 'validateAndLogInAppAndroidPurchase');
208+
expect(capturedArguments['publicKey'], 'publicKey');
209+
expect(capturedArguments['price'], '9.99');
210+
expect(capturedArguments['currency'], 'EUR');
183211
});
184212

185213
test('check setMinTimeBetweenSessions call', () async {
@@ -213,9 +241,13 @@ void main() {
213241
});
214242

215243
test('check setUserEmails call', () async {
216-
instance.setUserEmails(["emails"], EmailCryptType.EmailCryptTypeNone);
244+
instance.setUserEmails(
245+
["[email protected]"], EmailCryptType.EmailCryptTypeSHA256);
217246

218247
expect(selectedMethod, 'setUserEmails');
248+
expect(capturedArguments['emails'], contains('[email protected]'));
249+
expect(capturedArguments['cryptType'],
250+
EmailCryptType.values.indexOf(EmailCryptType.EmailCryptTypeSHA256));
219251
});
220252

221253
test('check setAdditionalData call', () async {
@@ -262,17 +294,14 @@ void main() {
262294

263295
test('check logAdRevenue call', () async {
264296
final adRevenueData = AdRevenueData(
265-
monetizationNetwork: 'GoogleAdMob',
266-
mediationNetwork: AFMediationNetwork.googleAdMob.value,
297+
monetizationNetwork: 'Applovin',
298+
mediationNetwork: AFMediationNetwork.applovinMax.value,
267299
currencyIso4217Code: 'USD',
268-
revenue: 1.23,
269-
additionalParameters: {
270-
'adUnitId': 'ca-app-pub-XXXX/YYYY',
271-
'ad_network_click_id': '12345'
272-
});
300+
revenue: 0.99);
273301
instance.logAdRevenue(adRevenueData);
274302

275303
expect(selectedMethod, 'logAdRevenue');
304+
expect(capturedArguments['mediationNetwork'], 'applovin_max');
276305
});
277306

278307
test('check setConsentData call', () async {
@@ -301,12 +330,15 @@ void main() {
301330
instance.setPartnerData('partnerId', {'key': 'value'});
302331

303332
expect(selectedMethod, 'setPartnerData');
333+
expect(capturedArguments['partnerId'], 'partnerId');
334+
expect(capturedArguments['partnersData']['key'], 'value');
304335
});
305336

306337
test('check setResolveDeepLinkURLs call', () async {
307338
instance.setResolveDeepLinkURLs(['https://example.com']);
308339

309340
expect(selectedMethod, 'setResolveDeepLinkURLs');
341+
expect(capturedArguments, contains('https://example.com'));
310342
});
311343

312344
test('check setPushNotification call', () async {
@@ -319,12 +351,14 @@ void main() {
319351
instance.sendPushNotificationData({'key': 'value'});
320352

321353
expect(selectedMethod, 'sendPushNotificationData');
354+
expect(capturedArguments['key'], 'value');
322355
});
323356

324357
test('check enableFacebookDeferredApplinks call', () async {
325358
instance.enableFacebookDeferredApplinks(true);
326359

327360
expect(selectedMethod, 'enableFacebookDeferredApplinks');
361+
expect(capturedArguments['isFacebookDeferredApplinksEnabled'], true);
328362
});
329363

330364
test('check disableSKAdNetwork call', () async {
@@ -337,6 +371,7 @@ void main() {
337371
instance.setDisableAdvertisingIdentifiers(true);
338372

339373
expect(selectedMethod, 'setDisableAdvertisingIdentifiers');
374+
expect(capturedArguments, true);
340375
});
341376
});
342377
}

0 commit comments

Comments
 (0)