Skip to content

Commit d0d2554

Browse files
committed
Update to 6.16.2 & AppsFlyerConsent update
Update iOS to 6.16.2 Update Android to 6.16.2 Update AppsflyerConsent object and methods + deprecation of old methods Fixing mediation network bug typo
1 parent af09dc9 commit d0d2554

File tree

11 files changed

+140
-85
lines changed

11 files changed

+140
-85
lines changed

Docs/RN_Installation.md

Lines changed: 0 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -137,45 +137,6 @@ So `getPackages()` should look like:
137137
}
138138
```
139139

140-
## Android Build Error Due to AGP Version
141-
142-
If you encounter the following error while building your project:
143-
```
144-
Execution failed for task ':app:mergeExtDexDebug'.
145-
> Could not resolve all files for configuration ':app:debugRuntimeClasspath'.
146-
> Failed to transform af-android-sdk-6.16.0.aar (com.appsflyer:af-android-sdk:6.16.0) to match attributes {artifactType=android-dex, asm-transformed-variant=NONE, dexing-enable-desugaring=true, dexing-is-debuggable=true, dexing-min-sdk=21, org.gradle.category=library, org.gradle.dependency.bundling=external, org.gradle.libraryelements=aar, org.gradle.status=release, org.gradle.usage=java-runtime}.
147-
> Execution failed for DexingWithClasspathTransform: /Users/amit.levy/.gradle/caches/transforms-3/fb46dcab411d99e4e97f01029413cab1/transformed/jetified-af-android-sdk-6.16.0-runtime.jar.
148-
> Error while dexing.
149-
```
150-
151-
This error occurs if you are using Android Gradle Plugin (AGP) below 8.2.0 due to a known bug in R8.
152-
Google has already resolved this issue
153-
[see Google Issue Tracker](https://issuetracker.google.com/issues/290412574?pli=1).
154-
155-
156-
### Solutions
157-
158-
To fix this issue, you have two options:
159-
1. Upgrade AGP to 8.2.0+ (Recommended):
160-
<br/>Updating AGP to 8.2.0 or later ensures compatibility with the latest R8 version.<br/>Sync and rebuild your project
161-
162-
2. Manually Override the R8 Version
163-
<br/>If upgrading AGP is not an option, you can manually set an external newer R8 version to override the bundled one.
164-
<br/> Open android/build.gradle and add this inside the buildscript {} block then sync and rebuild your project:
165-
```
166-
buildscript {
167-
repositories {
168-
mavenCentral()
169-
maven {
170-
url = uri("https://storage.googleapis.com/r8-releases/raw")
171-
}
172-
}
173-
dependencies {
174-
classpath("com.android.tools:r8:8.2.26")
175-
}
176-
}
177-
```
178-
179140
## Add strict-mode for App-kids
180141
Starting from version **6.1.10** iOS SDK comes in two variants: **Strict** mode and **Regular** mode. Please read more [here](https://dev.appsflyer.com/hc/docs/install-ios-sdk#strict-mode-sdk)
181142

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
- Tested with React-Native **v0.62.0** (older versions might be supported)
1818

1919
## <a id="breaking-changes"> ❗❗ Breaking changes when updating to v6.x.x❗❗
20-
- Starting from version `6.16.0`, Android minimum SDK version is 21.
20+
- Starting from version `6.16.2`, Android minimum SDK version is 21.
2121
<br/>Potential Build Issues: If you are using Android Gradle Plugin (AGP) below 8.2.0, you may encounter build errors on Android.
2222
<br/>To resolve this, refer to the [Android Build Error Due to AGP Version](./Docs/RN_Installation.md#android-build-error-due-to-agp-version).
2323

android/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,5 +55,5 @@ repositories {
5555
dependencies {
5656
implementation "com.facebook.react:react-native:${safeExtGet('reactNativeVersion', '+')}"
5757
implementation "com.android.installreferrer:installreferrer:${safeExtGet('installReferrerVersion', '2.1')}"
58-
api "com.appsflyer:af-android-sdk:${safeExtGet('appsflyerVersion', '6.16.0')}"
58+
api "com.appsflyer:af-android-sdk:${safeExtGet('appsflyerVersion', '6.16.2')}"
5959
}

android/src/main/java/com/appsflyer/reactnative/RNAppsFlyerConstants.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
public class RNAppsFlyerConstants {
88

9-
final static String PLUGIN_VERSION = "6.16.0";
9+
final static String PLUGIN_VERSION = "6.16.2";
1010
final static String NO_DEVKEY_FOUND = "No 'devKey' found or its empty";
1111
final static String UNKNOWN_ERROR = "AF Unknown Error";
1212
final static String SUCCESS = "Success";

android/src/main/java/com/appsflyer/reactnative/RNAppsFlyerModule.java

Lines changed: 34 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import android.os.Bundle;
99

1010
import androidx.annotation.NonNull;
11+
import androidx.annotation.Nullable;
1112

1213
import android.util.Log;
1314

@@ -876,17 +877,41 @@ public void enableTCFDataCollection(Boolean enabled) {
876877
}
877878

878879
@ReactMethod
879-
public void setConsentData(ReadableMap consentData) {
880+
public void setConsentData(@Nullable ReadableMap consentData) {
881+
if (consentData == null) {
882+
Log.e("AppsFlyer", "consentData is null");
883+
return;
884+
}
885+
880886
JSONObject JSONConsentData = RNUtil.readableMapToJson(consentData);
881-
boolean isUserSubjectToGDPR = JSONConsentData.optBoolean("isUserSubjectToGDPR");
882-
boolean hasConsentForDataUsage = JSONConsentData.optBoolean("hasConsentForDataUsage");
883-
boolean hasConsentForAdsPersonalization = JSONConsentData.optBoolean("hasConsentForAdsPersonalization");
884-
AppsFlyerConsent consentObject;
885-
if (isUserSubjectToGDPR) {
886-
consentObject = AppsFlyerConsent.forGDPRUser(hasConsentForDataUsage, hasConsentForAdsPersonalization);
887-
} else {
888-
consentObject = AppsFlyerConsent.forNonGDPRUser();
887+
if (JSONConsentData == null) {
888+
Log.e("AppsFlyer", "Failed to convert consentData to JSON");
889+
return;
889890
}
891+
892+
Boolean isUserSubjectToGDPR = JSONConsentData.has("isUserSubjectToGDPR") && !JSONConsentData.isNull("isUserSubjectToGDPR")
893+
? JSONConsentData.optBoolean("isUserSubjectToGDPR")
894+
: null;
895+
896+
Boolean hasConsentForDataUsage = JSONConsentData.has("hasConsentForDataUsage") && !JSONConsentData.isNull("hasConsentForDataUsage")
897+
? JSONConsentData.optBoolean("hasConsentForDataUsage")
898+
: null;
899+
900+
Boolean hasConsentForAdsPersonalization = JSONConsentData.has("hasConsentForAdsPersonalization") && !JSONConsentData.isNull("hasConsentForAdsPersonalization")
901+
? JSONConsentData.optBoolean("hasConsentForAdsPersonalization")
902+
: null;
903+
904+
Boolean hasConsentForAdStorage = JSONConsentData.has("hasConsentForAdStorage") && !JSONConsentData.isNull("hasConsentForAdStorage")
905+
? JSONConsentData.optBoolean("hasConsentForAdStorage")
906+
: null;
907+
908+
AppsFlyerConsent consentObject = new AppsFlyerConsent(
909+
isUserSubjectToGDPR,
910+
hasConsentForDataUsage,
911+
hasConsentForAdsPersonalization,
912+
hasConsentForAdStorage
913+
);
914+
890915
AppsFlyerLib.getInstance().setConsentData(consentObject);
891916
}
892917

index.d.ts

Lines changed: 37 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -114,11 +114,44 @@ declare module "react-native-appsflyer" {
114114
brandDomain?: string;
115115
}
116116

117-
export const AppsFlyerConsent: {
118-
forGDPRUser: (hasConsentForDataUsage: boolean, hasConsentForAdsPersonalization: boolean) => AppsFlyerConsentType;
119-
forNonGDPRUser: () => AppsFlyerConsentType;
117+
export class AppsFlyerConsent {
118+
isUserSubjectToGDPR?: boolean;
119+
hasConsentForDataUsage?: boolean;
120+
hasConsentForAdsPersonalization?: boolean;
121+
hasConsentForAdStorage?: boolean;
122+
123+
/**
124+
* Creates an instance of AppsFlyerConsent.
125+
* @param isUserSubjectToGDPR - Indicates whether GDPR applies to the user.
126+
* @param hasConsentForDataUsage - Indicates whether the user has consented to data usage.
127+
* @param hasConsentForAdsPersonalization - Indicates whether the user has consented to ads personalization.
128+
* @param hasConsentForAdStorage - Indicates whether the user has consented to ad storage.
129+
*/
130+
constructor(
131+
isUserSubjectToGDPR?: boolean,
132+
hasConsentForDataUsage?: boolean,
133+
hasConsentForAdsPersonalization?: boolean,
134+
hasConsentForAdStorage?: boolean
135+
) {}
136+
137+
/**
138+
* @deprecated since version 6.16.2. Use the AppsFlyerConsent constructor instead for more flexibility with optional booleans.
139+
*/
140+
static forGDPRUser(hasConsentForDataUsage: boolean, hasConsentForAdsPersonalization: boolean): AppsFlyerConsent {
141+
return new AppsFlyerConsent(true, hasConsentForDataUsage, hasConsentForAdsPersonalization);
142+
}
143+
144+
/**
145+
* @deprecated since version 6.16.2. Use the AppsFlyerConsent constructor instead for more flexibility with optional booleans.
146+
*/
147+
static forNonGDPRUser(): AppsFlyerConsent {
148+
return new AppsFlyerConsent(false);
149+
}
120150
}
121151

152+
/**
153+
* @deprecated since version 6.16.2. Use the AppsFlyerConsent class instead for a more integrated approach to consent management.
154+
*/
122155
export interface AppsFlyerConsentType {
123156
isUserSubjectToGDPR: boolean;
124157
hasConsentForDataUsage?: boolean;
@@ -190,7 +223,7 @@ declare module "react-native-appsflyer" {
190223
appendParametersToDeepLinkingURL(contains: string, parameters: object): void
191224
startSdk(): void
192225
enableTCFDataCollection(enabled: boolean): void
193-
setConsentData(consentData: AppsFlyerConsentType): void
226+
setConsentData(consentData: AppsFlyerConsent): void;
194227
logAdRevenue(adRevenueData: AFAdRevenueData) : void
195228
/**
196229
* For iOS Only

index.js

Lines changed: 35 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -672,25 +672,45 @@ function AFParseJSONException(_message, _data) {
672672
}
673673

674674
// Consent object
675-
export const AppsFlyerConsent = (function () {
676-
// Private constructor
677-
function AppsFlyerConsent(isUserSubjectToGDPR, hasConsentForDataUsage, hasConsentForAdsPersonalization) {
675+
export class AppsFlyerConsent {
676+
/**
677+
* Creates an instance of AppsFlyerConsent.
678+
* @param {boolean} [isUserSubjectToGDPR] - Indicates whether GDPR applies to the user.
679+
* @param {boolean} [hasConsentForDataUsage] - Indicates whether the user has consented to data usage.
680+
* @param {boolean} [hasConsentForAdsPersonalization] - Indicates whether the user has consented to ads personalization.
681+
* @param {boolean} [hasConsentForAdStorage] - Indicates whether the user has consented to ad storage.
682+
*/
683+
constructor(
684+
isUserSubjectToGDPR,
685+
hasConsentForDataUsage,
686+
hasConsentForAdsPersonalization,
687+
hasConsentForAdStorage
688+
) {
678689
this.isUserSubjectToGDPR = isUserSubjectToGDPR;
679690
this.hasConsentForDataUsage = hasConsentForDataUsage;
680691
this.hasConsentForAdsPersonalization = hasConsentForAdsPersonalization;
692+
this.hasConsentForAdStorage = hasConsentForAdStorage;
681693
}
682694

683-
return {
684-
// Factory method for GDPR user
685-
forGDPRUser: function(hasConsentForDataUsage, hasConsentForAdsPersonalization) {
686-
return new AppsFlyerConsent(true, hasConsentForDataUsage, hasConsentForAdsPersonalization);
687-
},
688-
689-
// Factory method for non GDPR user
690-
forNonGDPRUser: function() {
691-
return new AppsFlyerConsent(false, null, null);
692-
}
693-
};
694-
})();
695+
/**
696+
* @deprecated since version 6.16.2. Use the AppsFlyerConsent constructor instead for more flexibility with optional booleans.
697+
*/
698+
static forGDPRUser(hasConsentForDataUsage, hasConsentForAdsPersonalization) {
699+
console.warn(
700+
'AppsFlyerConsent.forGDPRUser is deprecated since version 6.16.2. Use the AppsFlyerConsent constructor instead for more flexibility with optional booleans.'
701+
);
702+
return new AppsFlyerConsent(true, hasConsentForDataUsage, hasConsentForAdsPersonalization);
703+
}
704+
705+
/**
706+
* @deprecated since version 6.16.2. Use the AppsFlyerConsent constructor instead for more flexibility with optional booleans.
707+
*/
708+
static forNonGDPRUser() {
709+
console.warn(
710+
'AppsFlyerConsent.forNonGDPRUser is deprecated since version 6.16.2. Use the AppsFlyerConsent constructor instead for more flexibility with optional booleans.'
711+
);
712+
return new AppsFlyerConsent(false);
713+
}
714+
}
695715

696716
export default appsFlyer;

ios/RNAppsFlyer.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
@end
2323

2424

25-
static NSString *const kAppsFlyerPluginVersion = @"6.16.0";
25+
static NSString *const kAppsFlyerPluginVersion = @"6.16.2";
2626
static NSString *const NO_DEVKEY_FOUND = @"No 'devKey' found or its empty";
2727
static NSString *const NO_APPID_FOUND = @"No 'appId' found or its empty";
2828
static NSString *const NO_EVENT_NAME_FOUND = @"No 'eventName' found or its empty";

ios/RNAppsFlyer.m

Lines changed: 27 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -640,20 +640,36 @@ - (BOOL)isExpoApp {
640640
[[AppsFlyerLib shared] enableTCFDataCollection:enabled];
641641
}
642642

643-
RCT_EXPORT_METHOD(setConsentData:(NSDictionary *)consentDictionary) {
644-
if (![consentDictionary isKindOfClass:[NSNull null]]) {
645-
BOOL isUserSubjectToGDPR = [consentDictionary[@"isUserSubjectToGDPR"] boolValue];
643+
RCT_EXPORT_METHOD(setConsentData:(nullable NSDictionary *)consentDictionary) {
644+
if (consentDictionary && [consentDictionary isKindOfClass:[NSDictionary class]]) {
645+
NSNumber *isUserSubjectToGDPR = consentDictionary[@"isUserSubjectToGDPR"];
646+
if ([isUserSubjectToGDPR isKindOfClass:[NSNull class]]) {
647+
isUserSubjectToGDPR = nil;
648+
}
646649

647-
AppsFlyerConsent *consentData;
648-
if (isUserSubjectToGDPR){
649-
BOOL hasConsentForDataUsage = [consentDictionary[@"hasConsentForDataUsage"] boolValue];
650-
BOOL hasConsentForAdsPersonalization = [consentDictionary[@"hasConsentForAdsPersonalization"] boolValue];
651-
consentData = [[AppsFlyerConsent alloc] initForGDPRUserWithHasConsentForDataUsage:hasConsentForDataUsage hasConsentForAdsPersonalization:hasConsentForAdsPersonalization];
652-
} else {
653-
consentData = [[AppsFlyerConsent alloc] initNonGDPRUser];
650+
NSNumber *hasConsentForDataUsage = consentDictionary[@"hasConsentForDataUsage"];
651+
if ([hasConsentForDataUsage isKindOfClass:[NSNull class]]) {
652+
hasConsentForDataUsage = nil;
654653
}
655-
654+
655+
NSNumber *hasConsentForAdsPersonalization = consentDictionary[@"hasConsentForAdsPersonalization"];
656+
if ([hasConsentForAdsPersonalization isKindOfClass:[NSNull class]]) {
657+
hasConsentForAdsPersonalization = nil;
658+
}
659+
660+
NSNumber *hasConsentForAdStorage = consentDictionary[@"hasConsentForAdStorage"];
661+
if ([hasConsentForAdStorage isKindOfClass:[NSNull class]]) {
662+
hasConsentForAdStorage = nil;
663+
}
664+
665+
AppsFlyerConsent *consentData = [[AppsFlyerConsent alloc] initWithIsUserSubjectToGDPR:isUserSubjectToGDPR
666+
hasConsentForDataUsage:hasConsentForDataUsage
667+
hasConsentForAdsPersonalization:hasConsentForAdsPersonalization
668+
hasConsentForAdStorage:hasConsentForAdStorage];
669+
656670
[[AppsFlyerLib shared] setConsentData:consentData];
671+
} else {
672+
NSLog(@"Invalid consentDictionary provided: %@", consentDictionary);
657673
}
658674
}
659675

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-native-appsflyer",
3-
"version": "6.16.0",
3+
"version": "6.16.2",
44
"description": "React Native Appsflyer plugin",
55
"main": "index.js",
66
"types": "index.d.ts",

0 commit comments

Comments
 (0)