Skip to content

Commit f420460

Browse files
authored
Releases/6.x.x/6.15.x/6.15.2 rc1 (#358)
* fixed the issue with MediationNetwork enums on Android * Added a usage example of the logAdRevenue api for testing. * Fix to the NullPointerException some clients face. * Versioning and change log
1 parent 6213341 commit f420460

File tree

12 files changed

+141
-85
lines changed

12 files changed

+141
-85
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
11
# Versions
2+
## 6.15.2
3+
- Fixed NullPointerException issue on Android that some clients had.
4+
- Fixed Android MediationNetwork enum issue.
5+
- Update iOS version to 6.15.3
6+
- Update Android version to 6.15.2
27
## 6.15.1
38
- Implementation of the new logAdRevenue API for iOS and Android
49
- Documentation update for the new logAdRevenue API

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212

1313
### <a id="plugin-build-for"> This plugin is built for
1414

15-
- Android AppsFlyer SDK **v6.15.1**
16-
- iOS AppsFlyer SDK **v6.15.1**
15+
- Android AppsFlyer SDK **v6.15.2**
16+
- iOS AppsFlyer SDK **v6.15.3**
1717

1818
## <a id="breaking-changes"> ❗❗ Breaking changes when updating to v6.x.x❗❗
1919

android/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,6 @@ android {
3131
dependencies {
3232
implementation fileTree(dir: 'libs', include: ['*.jar'])
3333
implementation 'androidx.appcompat:appcompat:1.0.0'
34-
implementation 'com.appsflyer:af-android-sdk:6.15.1'
34+
implementation 'com.appsflyer:af-android-sdk:6.15.2'
3535
implementation 'com.android.installreferrer:installreferrer:2.1'
3636
}
Lines changed: 27 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,32 @@
11
package com.appsflyer.appsflyersdk;
22

3-
public class AppsFlyerConstants {
4-
final static String PLUGIN_VERSION = "6.15.1";
5-
final static String AF_APP_INVITE_ONE_LINK = "appInviteOneLink";
6-
final static String AF_HOST_PREFIX = "hostPrefix";
7-
final static String AF_HOST_NAME = "hostName";
8-
final static String AF_IS_DEBUG = "isDebug";
9-
final static String AF_MANUAL_START = "manualStart";
10-
final static String AF_DEV_KEY = "afDevKey";
11-
final static String AF_EVENT_NAME = "eventName";
12-
final static String AF_EVENT_VALUES = "eventValues";
13-
final static String AF_ON_INSTALL_CONVERSION_DATA_LOADED = "onInstallConversionDataLoaded";
14-
final static String AF_ON_APP_OPEN_ATTRIBUTION = "onAppOpenAttribution";
15-
final static String AF_SUCCESS = "success";
16-
final static String AF_FAILURE = "failure";
17-
final static String AF_GCD = "GCD";
18-
final static String AF_UDL = "UDL";
19-
final static String AF_VALIDATE_PURCHASE = "validatePurchase";
20-
final static String AF_GCD_CALLBACK = "onInstallConversionData";
21-
final static String AF_OAOA_CALLBACK = "onAppOpenAttribution";
22-
final static String AF_UDL_CALLBACK = "onDeepLinking";
23-
final static String DISABLE_ADVERTISING_IDENTIFIER = "disableAdvertisingIdentifier";
3+
public final class AppsFlyerConstants {
4+
final static String PLUGIN_VERSION = "6.15.1";
5+
final static String AF_APP_INVITE_ONE_LINK = "appInviteOneLink";
6+
final static String AF_HOST_PREFIX = "hostPrefix";
7+
final static String AF_HOST_NAME = "hostName";
8+
final static String AF_IS_DEBUG = "isDebug";
9+
final static String AF_MANUAL_START = "manualStart";
10+
final static String AF_DEV_KEY = "afDevKey";
11+
final static String AF_EVENT_NAME = "eventName";
12+
final static String AF_EVENT_VALUES = "eventValues";
13+
final static String AF_ON_INSTALL_CONVERSION_DATA_LOADED = "onInstallConversionDataLoaded";
14+
final static String AF_ON_APP_OPEN_ATTRIBUTION = "onAppOpenAttribution";
15+
final static String AF_SUCCESS = "success";
16+
final static String AF_FAILURE = "failure";
17+
final static String AF_GCD = "GCD";
18+
final static String AF_UDL = "UDL";
19+
final static String AF_VALIDATE_PURCHASE = "validatePurchase";
20+
final static String AF_GCD_CALLBACK = "onInstallConversionData";
21+
final static String AF_OAOA_CALLBACK = "onAppOpenAttribution";
22+
final static String AF_UDL_CALLBACK = "onDeepLinking";
23+
final static String DISABLE_ADVERTISING_IDENTIFIER = "disableAdvertisingIdentifier";
2424

25-
final static String AF_EVENTS_CHANNEL = "af-events";
26-
final static String AF_METHOD_CHANNEL = "af-api";
27-
final static String AF_CALLBACK_CHANNEL = "callbacks";
25+
final static String AF_EVENTS_CHANNEL = "af-events";
26+
final static String AF_METHOD_CHANNEL = "af-api";
27+
final static String AF_CALLBACK_CHANNEL = "callbacks";
2828

29-
final static String AF_BROADCAST_ACTION_NAME = "com.appsflyer.appsflyersdk";
29+
final static String AF_BROADCAST_ACTION_NAME = "com.appsflyer.appsflyersdk";
30+
31+
final static String AF_PLUGIN_TAG = "AppsFlyer_FlutterPlugin";
3032
}

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

Lines changed: 30 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949

5050
import static com.appsflyer.appsflyersdk.AppsFlyerConstants.AF_EVENTS_CHANNEL;
5151
import static com.appsflyer.appsflyersdk.AppsFlyerConstants.AF_FAILURE;
52+
import static com.appsflyer.appsflyersdk.AppsFlyerConstants.AF_PLUGIN_TAG;
5253
import static com.appsflyer.appsflyersdk.AppsFlyerConstants.AF_SUCCESS;
5354

5455
/**
@@ -203,7 +204,7 @@ private void startListening(Object arguments, Result rawResult) {
203204
@Override
204205
public void onMethodCall(MethodCall call, Result result) {
205206
if (activity == null) {
206-
Log.d("AppsFlyer", "Activity isn't attached to the flutter engine");
207+
Log.d(AF_PLUGIN_TAG, LogMessages.ACTIVITY_NOT_ATTACHED_TO_ENGINE);
207208
return;
208209
}
209210
final String method = call.method;
@@ -362,11 +363,11 @@ private void performOnDeepLinking(MethodCall call, Result result) {
362363
AppsFlyerLib.getInstance().performOnDeepLinking(intent, mApplication);
363364
result.success(null);
364365
} else {
365-
Log.d("AppsFlyer", "performOnDeepLinking: intent is null!");
366+
Log.d(AF_PLUGIN_TAG, "performOnDeepLinking: intent is null!");
366367
result.error("NO_INTENT", "The intent is null", null);
367368
}
368369
} else {
369-
Log.d("AppsFlyer", "performOnDeepLinking: activity is null!");
370+
Log.d(AF_PLUGIN_TAG, "performOnDeepLinking: activity is null!");
370371
result.error("NO_ACTIVITY", "The current activity is null", null);
371372
}
372373
}
@@ -379,34 +380,37 @@ private void anonymizeUser(MethodCall call, Result result) {
379380

380381
private void startSDKwithHandler(MethodCall call, final Result result) {
381382
try {
382-
final AppsFlyerLib instance = AppsFlyerLib.getInstance();
383-
instance.start(activity, null, new AppsFlyerRequestListener() {
383+
final AppsFlyerLib appsFlyerLib = AppsFlyerLib.getInstance();
384+
385+
appsFlyerLib.start(activity, null, new AppsFlyerRequestListener() {
384386
@Override
385387
public void onSuccess() {
386-
uiThreadHandler.post(new Runnable() {
387-
@Override
388-
public void run() {
389-
mMethodChannel.invokeMethod("onSuccess", null);
390-
}
391-
});
388+
if (mMethodChannel != null) {
389+
uiThreadHandler.post(() -> mMethodChannel.invokeMethod("onSuccess", null));
390+
} else {
391+
Log.e(AF_PLUGIN_TAG, LogMessages.METHOD_CHANNEL_IS_NULL);
392+
result.error("NULL_OBJECT", LogMessages.METHOD_CHANNEL_IS_NULL, null);
393+
}
392394
}
393395

394396
@Override
395397
public void onError(final int errorCode, final String errorMessage) {
396-
uiThreadHandler.post(new Runnable() {
397-
@Override
398-
public void run() {
398+
if (mMethodChannel != null) {
399+
uiThreadHandler.post(() -> {
399400
HashMap<String, Object> errorDetails = new HashMap<>();
400401
errorDetails.put("errorCode", errorCode);
401402
errorDetails.put("errorMessage", errorMessage);
402403
mMethodChannel.invokeMethod("onError", errorDetails);
403-
}
404-
});
404+
});
405+
} else {
406+
Log.e(AF_PLUGIN_TAG, LogMessages.METHOD_CHANNEL_IS_NULL);
407+
result.error("NULL_OBJECT", LogMessages.METHOD_CHANNEL_IS_NULL, null);
408+
}
405409
}
406410
});
407411
result.success(null);
408-
} catch (Exception e) {
409-
result.error("UNEXPECTED_ERROR", e.getMessage(), null);
412+
} catch (Throwable t) {
413+
result.error("UNEXPECTED_ERROR", t.getMessage(), null);
410414
}
411415
}
412416

@@ -532,14 +536,14 @@ private void sendPushNotificationData(MethodCall call, Result result) {
532536
Bundle bundle;
533537

534538
if (pushPayload == null) {
535-
Log.d("AppsFlyer", "Push payload is null");
539+
Log.d(AF_PLUGIN_TAG, "Push payload is null");
536540
return;
537541
}
538542

539543
try {
540544
bundle = this.jsonToBundle(new JSONObject(pushPayload));
541545
} catch (JSONException e) {
542-
Log.d("AppsFlyer", "Can't parse pushPayload to bundle");
546+
Log.d(AF_PLUGIN_TAG, "Can't parse pushPayload to bundle");
543547
return;
544548
}
545549

@@ -557,7 +561,7 @@ private void sendPushNotificationData(MethodCall call, Result result) {
557561
}
558562

559563
if (errorMsg != null) {
560-
Log.d("AppsFlyer", errorMsg);
564+
Log.d(AF_PLUGIN_TAG, errorMsg);
561565
return;
562566
}
563567

@@ -963,8 +967,8 @@ private void logAdRevenue(MethodCall call, Result result) {
963967
try {
964968
String monetizationNetwork = requireNonNullArgument(call, "monetizationNetwork");
965969
String currencyIso4217Code = requireNonNullArgument(call, "currencyIso4217Code");
966-
double revenue = requireNonNullArgument(call,"revenue");
967-
String mediationNetworkString = requireNonNullArgument(call,"mediationNetwork");
970+
double revenue = requireNonNullArgument(call, "revenue");
971+
String mediationNetworkString = requireNonNullArgument(call, "mediationNetwork");
968972

969973
MediationNetwork mediationNetwork = MediationNetwork.valueOf(mediationNetworkString.toUpperCase());
970974

@@ -984,10 +988,9 @@ private void logAdRevenue(MethodCall call, Result result) {
984988
} catch (IllegalArgumentException e) {
985989
// The IllegalArgumentException could come from either requireNonNullArgument or valueOf methods.
986990
result.error("INVALID_ARGUMENT_PROVIDED", e.getMessage(), null);
987-
}
988-
catch (Throwable t) {
991+
} catch (Throwable t) {
989992
result.error("UNEXPECTED_ERROR", "[logAdRevenue]: An unexpected error occurred: " + t.getMessage(), null);
990-
Log.e("AppsFlyer", "Unexpected exception occurred: [logAdRevenue]", t);
993+
Log.e(AF_PLUGIN_TAG, "Unexpected exception occurred: [logAdRevenue]", t);
991994
}
992995
}
993996

@@ -1004,7 +1007,7 @@ private void logAdRevenue(MethodCall call, Result result) {
10041007
private <T> T requireNonNullArgument(MethodCall call, String argumentName) throws IllegalArgumentException {
10051008
T argument = call.argument(argumentName);
10061009
if (argument == null) {
1007-
Log.e("AppsFlyer", "Exception occurred when trying to: " + call.method + "->" + argumentName + " must not be null");
1010+
Log.e(AF_PLUGIN_TAG, "Exception occurred when trying to: " + call.method + "->" + argumentName + " must not be null");
10081011
throw new IllegalArgumentException("[" + call.method + "]: " + argumentName + " must not be null");
10091012
}
10101013
return argument;
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
package com.appsflyer.appsflyersdk;
2+
3+
public final class LogMessages {
4+
5+
// Prevent the instantiation of this utilities class.
6+
private LogMessages() {
7+
throw new IllegalStateException("LogMessages class should not be instantiated");
8+
}
9+
10+
public static final String METHOD_CHANNEL_IS_NULL = "mMethodChannel is null, cannot invoke the callback";
11+
public static final String ACTIVITY_NOT_ATTACHED_TO_ENGINE = "Activity isn't attached to the flutter engine";
12+
}

example/lib/home_container.dart

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,14 @@ import 'utils.dart';
77
class HomeContainer extends StatefulWidget {
88
final Map onData;
99
final Future<bool?> Function(String, Map) logEvent;
10+
final void Function() logAdRevenueEvent;
1011
Object deepLinkData;
1112

1213
HomeContainer({
1314
required this.onData,
1415
required this.deepLinkData,
1516
required this.logEvent,
17+
required this.logAdRevenueEvent,
1618
});
1719

1820
@override
@@ -136,6 +138,20 @@ class _HomeContainerState extends State<HomeContainer> {
136138
),
137139
),
138140
),
141+
ElevatedButton(
142+
onPressed: () {
143+
widget.logAdRevenueEvent();
144+
},
145+
child: Text("Trigger AdRevenue Event"),
146+
style: ElevatedButton.styleFrom(
147+
backgroundColor: Colors.white,
148+
padding: EdgeInsets.symmetric(horizontal: 20, vertical: 10),
149+
textStyle: TextStyle(
150+
fontWeight: FontWeight.bold,
151+
fontSize: 16,
152+
),
153+
),
154+
),
139155
],
140156
),
141157
)

example/lib/main_page.dart

Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ class MainPageState extends State<MainPage> {
124124
onData: _gcd,
125125
deepLinkData: _deepLinkData,
126126
logEvent: logEvent,
127+
logAdRevenueEvent: logAdRevenueEvent,
127128
),
128129
),
129130
ElevatedButton(
@@ -133,7 +134,8 @@ class MainPageState extends State<MainPage> {
133134
showMessage("AppsFlyer SDK initialized successfully.");
134135
},
135136
onError: (int errorCode, String errorMessage) {
136-
showMessage("Error initializing AppsFlyer SDK: Code $errorCode - $errorMessage");
137+
showMessage(
138+
"Error initializing AppsFlyer SDK: Code $errorCode - $errorMessage");
137139
},
138140
);
139141
},
@@ -158,13 +160,29 @@ class MainPageState extends State<MainPage> {
158160
return logResult;
159161
}
160162

163+
void logAdRevenueEvent() {
164+
try {
165+
Map<String, String> customParams = {
166+
'ad_platform': 'Admob',
167+
'ad_currency': 'USD',
168+
};
169+
170+
AdRevenueData adRevenueData = AdRevenueData(
171+
monetizationNetwork: 'SpongeBob',
172+
mediationNetwork: AFMediationNetwork.googleAdMob.value,
173+
currencyIso4217Code: 'USD',
174+
revenue: 100.3,
175+
additionalParameters: customParams);
176+
_appsflyerSdk.logAdRevenue(adRevenueData);
177+
print("Ad Revenue event logged with no errors");
178+
} catch (e) {
179+
print("Failed to log event: $e");
180+
}
181+
}
182+
161183
void showMessage(String message) {
162-
ScaffoldMessenger.of(context)
163-
.showSnackBar(SnackBar(
164-
content:
165-
Text(message),
184+
ScaffoldMessenger.of(context).showSnackBar(SnackBar(
185+
content: Text(message),
166186
));
167187
}
168188
}
169-
170-

ios/Classes/AppsflyerSdkPlugin.m

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -255,20 +255,20 @@ - (void)logAdRevenue:(FlutterMethodCall*)call result:(FlutterResult)result {
255255

256256
- (AppsFlyerAdRevenueMediationNetworkType)getEnumValueFromString:(NSString *)mediationNetworkString {
257257
NSDictionary<NSString *, NSNumber *> *stringToEnumMap = @{
258-
@"googleadmob": @(AppsFlyerAdRevenueMediationNetworkTypeGoogleAdMob),
258+
@"google_admob": @(AppsFlyerAdRevenueMediationNetworkTypeGoogleAdMob),
259259
@"ironsource": @(AppsFlyerAdRevenueMediationNetworkTypeIronSource),
260-
@"applovinmax": @(AppsFlyerAdRevenueMediationNetworkTypeApplovinMax),
260+
@"applovin_max": @(AppsFlyerAdRevenueMediationNetworkTypeApplovinMax),
261261
@"fyber": @(AppsFlyerAdRevenueMediationNetworkTypeFyber),
262262
@"appodeal": @(AppsFlyerAdRevenueMediationNetworkTypeAppodeal),
263-
@"Admost": @(AppsFlyerAdRevenueMediationNetworkTypeAdmost),
264-
@"Topon": @(AppsFlyerAdRevenueMediationNetworkTypeTopon),
265-
@"Tradplus": @(AppsFlyerAdRevenueMediationNetworkTypeTradplus),
266-
@"Yandex": @(AppsFlyerAdRevenueMediationNetworkTypeYandex),
263+
@"admost": @(AppsFlyerAdRevenueMediationNetworkTypeAdmost),
264+
@"topon": @(AppsFlyerAdRevenueMediationNetworkTypeTopon),
265+
@"tradplus": @(AppsFlyerAdRevenueMediationNetworkTypeTradplus),
266+
@"yandex": @(AppsFlyerAdRevenueMediationNetworkTypeYandex),
267267
@"chartboost": @(AppsFlyerAdRevenueMediationNetworkTypeChartBoost),
268-
@"Unity": @(AppsFlyerAdRevenueMediationNetworkTypeUnity),
269-
@"toponpte": @(AppsFlyerAdRevenueMediationNetworkTypeToponPte),
270-
@"customMediation": @(AppsFlyerAdRevenueMediationNetworkTypeCustom),
271-
@"directMonetizationNetwork": @(AppsFlyerAdRevenueMediationNetworkTypeDirectMonetization)
268+
@"unity": @(AppsFlyerAdRevenueMediationNetworkTypeUnity),
269+
@"topon_pte": @(AppsFlyerAdRevenueMediationNetworkTypeToponPte),
270+
@"custom_mediation": @(AppsFlyerAdRevenueMediationNetworkTypeCustom),
271+
@"direct_monetization_network": @(AppsFlyerAdRevenueMediationNetworkTypeDirectMonetization)
272272
};
273273

274274
NSNumber *enumValueNumber = stringToEnumMap[mediationNetworkString];

ios/appsflyer_sdk.podspec

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
#
44
Pod::Spec.new do |s|
55
s.name = 'appsflyer_sdk'
6-
s.version = '6.15.1'
6+
s.version = '6.15.3'
77
s.summary = 'AppsFlyer Integration for Flutter'
88
s.description = <<-DESC
99
AppsFlyer is the market leader in mobile advertising attribution & analytics, helping marketers to pinpoint their targeting, optimize their ad spend and boost their ROI.
@@ -21,5 +21,5 @@ AppsFlyer is the market leader in mobile advertising attribution & analytics, he
2121
s.source_files = 'Classes/**/*'
2222
s.public_header_files = 'Classes/**/*.h'
2323
s.dependency 'Flutter'
24-
s.ios.dependency 'AppsFlyerFramework','6.15.1'
24+
s.ios.dependency 'AppsFlyerFramework','6.15.3'
2525
end

0 commit comments

Comments
 (0)