Skip to content

Commit 5ab2580

Browse files
authored
Releases/6.x.x/6.16.x/6.16.2-rc1 into master (#385)
- setConsentData is now deprecated! - setConsentDataV2 is the new and recommended way to set manual user consent. - Added getVersionNumber, returns the plugin's version. - Fixed typos within the code. - Fixed and updated tests and their frameworks. - Push notification measurement API's documentation has been updated. - Closed a few potential memory leaks. - Update iOS version to 6.16.2 - Update Android version to 6.16.2 - Updated entire example project.
1 parent f420460 commit 5ab2580

29 files changed

+640
-202
lines changed

.gitignore

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,8 @@ example/windows/*
105105

106106
example/web/*
107107

108+
example/android/app/.cxx
109+
108110
example/\.metadata
109111
example/analysis_options.yaml
110112

@@ -114,9 +116,3 @@ node_modules/
114116
covBadgeGen.js
115117
coverage/
116118
.env
117-
example/windows/*
118-
example/macos/*
119-
example/linux/*
120-
example/web/*
121-
example/analysis_options.yaml
122-

CHANGELOG.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,14 @@
11
# Versions
2+
## 6.16.2
3+
- setConsentData is now deprecated!
4+
- setConsentDataV2 is the new and recommended way to set manual user consent.
5+
- Added getVersionNumber, returns the plugin's version.
6+
- Fixed typos within the code.
7+
- Fixed and updated tests and their frameworks.
8+
- Push notification measurment API's documentation has been updated.
9+
- Closed a few potential memory leaks.
10+
- Update iOS version to 6.16.2
11+
- Update Android version to 6.16.2
212
## 6.15.2
313
- Fixed NullPointerException issue on Android that some clients had.
414
- Fixed Android MediationNetwork enum issue.

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.2**
16-
- iOS AppsFlyer SDK **v6.15.3**
15+
- Android AppsFlyer SDK **v6.16.2**
16+
- iOS AppsFlyer SDK **v6.16.2**
1717

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

android/build.gradle

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,12 @@ rootProject.allprojects {
1414
}
1515
}
1616
apply plugin: 'com.android.library'
17+
apply plugin: 'org.jetbrains.kotlin.android'
18+
1719
android {
1820
defaultConfig {
19-
minSdkVersion 16
20-
compileSdk 31
21+
minSdkVersion 19
22+
compileSdk 35
2123
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
2224

2325
multiDexEnabled true
@@ -26,11 +28,21 @@ android {
2628
disable 'InvalidPackage'
2729
}
2830
namespace 'com.appsflyer.appsflyersdk'
31+
32+
compileOptions {
33+
sourceCompatibility JavaVersion.VERSION_17
34+
targetCompatibility JavaVersion.VERSION_17
35+
}
36+
37+
kotlinOptions {
38+
jvmTarget = '17'
39+
}
40+
2941
}
3042

3143
dependencies {
3244
implementation fileTree(dir: 'libs', include: ['*.jar'])
3345
implementation 'androidx.appcompat:appcompat:1.0.0'
34-
implementation 'com.appsflyer:af-android-sdk:6.15.2'
46+
implementation 'com.appsflyer:af-android-sdk:6.16.2'
3547
implementation 'com.android.installreferrer:installreferrer:2.1'
3648
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-bin.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-bin.zip
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package com.appsflyer.appsflyersdk;
22

33
public final class AppsFlyerConstants {
4-
final static String PLUGIN_VERSION = "6.15.1";
4+
final static String PLUGIN_VERSION = "6.16.2";
55
final static String AF_APP_INVITE_ONE_LINK = "appInviteOneLink";
66
final static String AF_HOST_PREFIX = "hostPrefix";
77
final static String AF_HOST_NAME = "hostName";

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

Lines changed: 45 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@
5252
import static com.appsflyer.appsflyersdk.AppsFlyerConstants.AF_PLUGIN_TAG;
5353
import static com.appsflyer.appsflyersdk.AppsFlyerConstants.AF_SUCCESS;
5454

55+
import androidx.annotation.NonNull;
56+
5557
/**
5658
* AppsflyerSdkPlugin
5759
*/
@@ -72,7 +74,6 @@ public class AppsflyerSdkPlugin implements MethodCallHandler, FlutterPlugin, Act
7274
//private FlutterView mFlutterView;
7375
private Context mContext;
7476
private Application mApplication;
75-
private Intent mIntent;
7677
private MethodChannel mMethodChannel;
7778
private MethodChannel mCallbackChannel;
7879
private Activity activity;
@@ -175,7 +176,6 @@ private void onAttachedToEngine(Context applicationContext, BinaryMessenger mess
175176
mMethodChannel.setMethodCallHandler(this);
176177
mCallbackChannel = new MethodChannel(messenger, AppsFlyerConstants.AF_CALLBACK_CHANNEL);
177178
mCallbackChannel.setMethodCallHandler(callbacksHandler);
178-
179179
}
180180

181181

@@ -205,6 +205,7 @@ private void startListening(Object arguments, Result rawResult) {
205205
public void onMethodCall(MethodCall call, Result result) {
206206
if (activity == null) {
207207
Log.d(AF_PLUGIN_TAG, LogMessages.ACTIVITY_NOT_ATTACHED_TO_ENGINE);
208+
result.error("NO_ACTIVITY", "The current activity is null", null);
208209
return;
209210
}
210211
final String method = call.method;
@@ -233,6 +234,9 @@ public void onMethodCall(MethodCall call, Result result) {
233234
case "setConsentData":
234235
setConsentData(call, result);
235236
break;
237+
case "setConsentDataV2":
238+
setConsentDataV2(call, result);
239+
break;
236240
case "setIsUpdate":
237241
setIsUpdate(call, result);
238242
break;
@@ -424,6 +428,11 @@ private void startSDK(MethodCall call, final Result result) {
424428
result.success(null);
425429
}
426430

431+
/**
432+
* Sets the user consent data for tracking.
433+
* @deprecated Use {@link #setConsentDataV2(MethodCall, Result)} instead.
434+
*/
435+
@Deprecated
427436
public void setConsentData(MethodCall call, Result result) {
428437
Map<String, Object> arguments = (Map<String, Object>) call.arguments;
429438
Map<String, Object> consentDict = (Map<String, Object>) arguments.get("consentData");
@@ -445,6 +454,35 @@ public void setConsentData(MethodCall call, Result result) {
445454
result.success(null);
446455
}
447456

457+
/**
458+
* Sets the user consent data for tracking with flexible parameters.
459+
*/
460+
public void setConsentDataV2(MethodCall call, Result result) {
461+
try {
462+
AppsFlyerConsent consent = getAppsFlyerConsentFromCall(call);
463+
AppsFlyerLib.getInstance().setConsentData(consent);
464+
result.success(null);
465+
} catch (Exception e) {
466+
Log.e(AF_PLUGIN_TAG, LogMessages.ERROR_WHILE_SETTING_CONSENT + e.getMessage(), e);
467+
result.error("CONSENT_ERROR", LogMessages.ERROR_WHILE_SETTING_CONSENT + e.getMessage(), null);
468+
}
469+
}
470+
471+
@NonNull
472+
@SuppressWarnings("unchecked")
473+
private AppsFlyerConsent getAppsFlyerConsentFromCall(MethodCall call) {
474+
Map<String, Object> args = (Map<String, Object>) call.arguments;
475+
476+
// Extract nullable Boolean arguments
477+
Boolean isUserSubjectToGDPR = (Boolean) args.get("isUserSubjectToGDPR");
478+
Boolean consentForDataUsage = (Boolean) args.get("consentForDataUsage");
479+
Boolean consentForAdsPersonalization = (Boolean) args.get("consentForAdsPersonalization");
480+
Boolean hasConsentForAdStorage = (Boolean) args.get("hasConsentForAdStorage");
481+
482+
// Create and return AppsFlyerConsent object with the given parameters
483+
return new AppsFlyerConsent(isUserSubjectToGDPR, consentForDataUsage, consentForAdsPersonalization, hasConsentForAdStorage);
484+
}
485+
448486
private void enableTCFDataCollection(MethodCall call, Result result) {
449487
boolean shouldCollect = (boolean) call.argument("shouldCollect");
450488
AppsFlyerLib.getInstance().enableTCFDataCollection(shouldCollect);
@@ -1075,31 +1113,33 @@ public void onDetachedFromEngine(FlutterPluginBinding binding) {
10751113
mMethodChannel = null;
10761114
mEventChannel.setStreamHandler(null);
10771115
mEventChannel = null;
1116+
mContext = null;
1117+
mApplication = null;
10781118
}
10791119

10801120
@Override
10811121
public void onAttachedToActivity(ActivityPluginBinding binding) {
10821122
activity = binding.getActivity();
1083-
mIntent = binding.getActivity().getIntent();
10841123
mApplication = binding.getActivity().getApplication();
10851124
binding.addOnNewIntentListener(onNewIntentListener);
10861125
}
10871126

10881127
@Override
10891128
public void onDetachedFromActivityForConfigChanges() {
1090-
1129+
this.activity = null;
10911130
}
10921131

10931132
@Override
10941133
public void onReattachedToActivityForConfigChanges(ActivityPluginBinding binding) {
10951134
sendCachedCallbacksToDart();
10961135
binding.addOnNewIntentListener(onNewIntentListener);
1136+
activity = binding.getActivity();
10971137
}
10981138

10991139
@Override
11001140
public void onDetachedFromActivity() {
11011141
activity = null;
11021142
saveCallbacks = true;
1143+
AppsFlyerLib.getInstance().unregisterConversionListener();
11031144
}
1104-
11051145
}

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,5 @@ private LogMessages() {
99

1010
public static final String METHOD_CHANNEL_IS_NULL = "mMethodChannel is null, cannot invoke the callback";
1111
public static final String ACTIVITY_NOT_ATTACHED_TO_ENGINE = "Activity isn't attached to the flutter engine";
12+
public static final String ERROR_WHILE_SETTING_CONSENT = "Error while setting consent data: ";
1213
}

0 commit comments

Comments
 (0)