appsflyer-react-native-plugin
appsflyer-react-native-plugin copied to clipboard
setConsentData type issue
Hi! 👋
Firstly, thanks for your work on this project! 🙂
Today I used patch-package to patch [email protected] for the project I'm working on.
Here is the diff that solved my problem:
diff --git a/node_modules/react-native-appsflyer/index.d.ts b/node_modules/react-native-appsflyer/index.d.ts
index e1ae493..ba6ace1 100644
--- a/node_modules/react-native-appsflyer/index.d.ts
+++ b/node_modules/react-native-appsflyer/index.d.ts
@@ -115,8 +115,8 @@ declare module "react-native-appsflyer" {
}
export const AppsFlyerConsent: {
- forGDPRUser: (hasConsentForDataUsage: boolean, hasConsentForAdsPersonalization: boolean) => void;
- forNonGDPRUser: () => void;
+ forGDPRUser: (hasConsentForDataUsage: boolean, hasConsentForAdsPersonalization: boolean) => AppsFlyerConsentType;
+ forNonGDPRUser: () => AppsFlyerConsentType;
}
export type AppsFlyerConsentType = typeof AppsFlyerConsent;
This issue body was partially generated by patch-package.
I believe the proposed patch above doesn't go far enough in correcting the broken types. The following should actually fix the issue (ensuring that the object returned from forGDPRUser and forNonGDPRUser actually matches the expected type (an object containing isUserSubjectToGDPR, hasConsentForDataUsage and hasConsentForAdsPersonalization) based on the two platform specific implementations :
- iOS setConsentData
- Android setConsentData
diff --git a/node_modules/react-native-appsflyer/index.d.ts b/node_modules/react-native-appsflyer/index.d.ts
index e1ae493..d6d8442 100644
--- a/node_modules/react-native-appsflyer/index.d.ts
+++ b/node_modules/react-native-appsflyer/index.d.ts
@@ -115,11 +115,15 @@ declare module "react-native-appsflyer" {
}
export const AppsFlyerConsent: {
- forGDPRUser: (hasConsentForDataUsage: boolean, hasConsentForAdsPersonalization: boolean) => void;
- forNonGDPRUser: () => void;
+ forGDPRUser: (hasConsentForDataUsage: boolean, hasConsentForAdsPersonalization: boolean) => AppsFlyerConsentType;
+ forNonGDPRUser: () => AppsFlyerConsentType;
}
- export type AppsFlyerConsentType = typeof AppsFlyerConsent;
+ export interface AppsFlyerConsentType {
+ isUserSubjectToGDPR: boolean;
+ hasConsentForDataUsage?: boolean;
+ hasConsentForAdsPersonalization?: boolean;
+ }
const appsFlyer: {
onInstallConversionData(callback: (data: ConversionData) => any): () => void;
@amit-kremer93 can we get a fix for this merged. Seems like its very important with the March 6th deadline quickly approaching
+1
@chriskurzeja @artyorsh thanks for the above. Super helpful.
Just wondering what method did you use to determine if the user was in a GDPR region or not? I was thinking to use the Timezone string to determine. Been keen to see if there is a better way
@chriskurzeja @artyorsh thanks for the above. Super helpful.
Just wondering what method did you use to determine if the user was in a GDPR region or not? I was thinking to use the Timezone string to determine. Been keen to see if there is a better way
A bit different for us since I work on "EU only" app. But I guess I'd rely on IP ranges.
Fixed in 6.13.1
Hello, on 6.17.1 this issue is back.
Trying the exact code from the documentation:
const consentData = new AppsFlyerConsent(true, true, true, true); // Send consent data to the SDK appsFlyer.setConsentData(consentData);
will return this typescript issue:
Argument of type 'AppsFlyerConsent' is not assignable to parameter of type 'AppsFlyerConsentType'. Property 'isUserSubjectToGDPR' is optional in type 'AppsFlyerConsent' but required in type 'AppsFlyerConsentType'.ts(2345)