appsflyer-capacitor-plugin 6.12.1 → 6.13.0-rc1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -14,16 +14,16 @@
14
14
 
15
15
  ### <a id="plugin-build-for"> This plugin is built for
16
16
 
17
- - Android AppsFlyer SDK **6.12.1**
18
- - iOS AppsFlyer SDK **6.12.1**
17
+ - Android AppsFlyer SDK **6.13.0**
18
+ - iOS AppsFlyer SDK **6.13.0**
19
19
 
20
- ## <a id="breaking-changes-6-12-1"> ❗❗ Breaking changes when updating to v6.12.1❗❗
20
+ ## <a id="breaking-changes-6-12-1"> ❗❗ Breaking changes when updating to v6.12.1 ❗❗
21
21
  Starting from v6.12.1, this plugin works only with Capacitor 5. </br>
22
22
  If you are still interested in using Capacitor 4, please follow the instructions [here](/docs/Installation.md#cap4) to install the latest version that supports Capacitor 4.
23
23
 
24
24
 
25
25
 
26
- ## <a id="breaking-changes"> ❗❗ Breaking changes when updating to v6.9.2❗❗
26
+ ## <a id="breaking-changes"> ❗❗ Breaking changes when updating to v6.9.2 ❗❗
27
27
  Starting from v6.9.2, this plugin works only with Capacitor 4. </br>
28
28
  If you are still interested in using Capacitor 3, please follow the instructions [here](/docs/Installation.md#cap3) to install the latest version that supports Capacitor 3.
29
29
 
@@ -37,9 +37,10 @@ If you are still interested in using Capacitor 3, please follow the instructions
37
37
 
38
38
  ## 📖 Guides
39
39
  - [Adding the SDK to your project](/docs/Installation.md)
40
- - [Initializing the SDK](/docs/BasicIntegration.md)
40
+ - [Initializing The SDK](/docs/BasicIntegration.md)
41
41
  - [In-app Events](/docs/InAppEvents.md)
42
42
  - [Deep Linking](/docs/DeepLink.md)
43
43
  - [Advanced API](/docs/AdvancedAPI.md)
44
- - [Testing the integration](/docs/Testing.md)
44
+ - [Testing The integration](/docs/Testing.md)
45
45
  - [API](/docs/API.md)
46
+ - [Set Consent For DMA Compliance](/docs/DMA.md)
@@ -1,11 +1,74 @@
1
- // On top of your file import a JSON parser
2
1
  import groovy.json.JsonSlurper
3
2
 
3
+ import java.nio.file.FileVisitResult
4
+ import java.nio.file.Files
5
+ import java.nio.file.Path
6
+ import java.nio.file.SimpleFileVisitor
7
+ import java.nio.file.attribute.BasicFileAttributes
8
+
9
+ String getPackageJsonPath() {
10
+ return findProperty("APPSFLYER_PACKAGE_JSON") ?: "$rootDir/../node_modules/appsflyer-capacitor-plugin/package.json"
11
+ }
12
+
13
+ def findNodeModulesDir(File currentDir) {
14
+ def dir = currentDir
15
+ while (dir != null) {
16
+ def nodeModulesDir = new File(dir, 'node_modules')
17
+ if (nodeModulesDir.exists()) {
18
+ return nodeModulesDir
19
+ }
20
+ dir = dir.parentFile
21
+ }
22
+ return null
23
+ }
24
+
25
+ def findPackageJsonInDep(String packageName) {
26
+ def nodeModulesDir = findNodeModulesDir(project.rootDir)
27
+ if (nodeModulesDir == null) {
28
+ println "node_modules directory not found in any parent directories."
29
+ return null
30
+ }
31
+
32
+ def json = null
33
+
34
+ def walker = new SimpleFileVisitor<Path>() {
35
+ @Override
36
+ FileVisitResult visitFile(Path file, BasicFileAttributes attrs) {
37
+ if (file.toAbsolutePath().endsWith("appsflyer-capacitor-plugin/package.json")) {
38
+ try {
39
+ def content = new JsonSlurper().parseText(file.toFile().text)
40
+ if (content.name == packageName) {
41
+ println "Found package.json: ${file.toAbsolutePath()}"
42
+ json = content
43
+ return FileVisitResult.TERMINATE
44
+ }
45
+ } catch (Exception e) {
46
+ println "Error parsing JSON in file: ${file.toAbsolutePath().toString()}\n${e.message}\n\t"
47
+ }
48
+ }
49
+ return FileVisitResult.CONTINUE
50
+ }
51
+ }
52
+ while (json == null && nodeModulesDir != null) {
53
+ Files.walkFileTree(nodeModulesDir.toPath(), walker)
54
+ // parentFile will give us exact same directory so we have to go 2 level upper
55
+ // and find another node_modules
56
+ nodeModulesDir = findNodeModulesDir(nodeModulesDir.parentFile.parentFile)
57
+ }
58
+ return json
59
+ }
60
+
4
61
  def getPackageJson() {
5
- // Read and parse package.json file from project root
6
- def dir = "$rootDir/../node_modules/appsflyer-capacitor-plugin/package.json"
7
- def inputFile = new File(dir)
8
- def packageJson = new JsonSlurper().parseText(inputFile.text)
62
+ def packageJson
63
+ def inputFile = new File(getPackageJsonPath())
64
+ if (inputFile.exists()) {
65
+ println "found package.json from ENV variable"
66
+ packageJson = new JsonSlurper().parseText(inputFile.text)
67
+ } else {
68
+ println "could not found package.json from ENV variable"
69
+ println "searching for package.json recursively"
70
+ packageJson = findPackageJsonInDep("appsflyer-capacitor-plugin")
71
+ }
9
72
  return packageJson
10
73
  }
11
74
  // Create an easy to use function
@@ -19,6 +82,7 @@ def getSDKVersionFromNpm() {
19
82
  // Return the version, you can get any value this way
20
83
  return getPackageJson()["androidSdkVersion"]
21
84
  }
85
+
22
86
  def getPluginBuildVersionFromNpm() {
23
87
  // Return the version, you can get any value this way
24
88
  return getPackageJson()["buildNumber"]
@@ -59,3 +59,9 @@ const val AF_DATA = "data"
59
59
  const val AF_PARTNER_ID = "partnerId"
60
60
  const val AF_DEEP_LINK_TIME_OUT = "deepLinkTimeout"
61
61
  const val AF_EVENT_PARAMETERS = "eventParameters"
62
+ const val AF_ENABLE_TCF_DATA_COLLECTION = "shouldEnableTCFDataCollection"
63
+ const val AF_MANUAL_START = "manualStart"
64
+ const val AF_IS_SUBJECTED_TO_GDPR = "isUserSubjectToGDPR"
65
+ const val AF_CONSENT_FOR_DATA_USAGE = "hasConsentForDataUsage"
66
+ const val AF_CONSENT_FOR_ADS_PERSONALIZATION = "hasConsentForAdsPersonalization"
67
+
@@ -49,6 +49,7 @@ class AppsFlyerPlugin : Plugin() {
49
49
  val devKey = call.getString(AF_DEV_KEY)
50
50
  val debug = call.getBoolean(AF_DEBUG, false)
51
51
  val minTime = call.getInt(AF_MIN_TIME)
52
+ val manualStart = call.getBoolean(AF_MANUAL_START, false)
52
53
  conversion = call.getBoolean(AF_CONVERSION_LISTENER, true)
53
54
  oaoa = call.getBoolean(AF_OAOA, true)
54
55
  udl = call.getBoolean(AF_UDL, false)
@@ -59,7 +60,7 @@ class AppsFlyerPlugin : Plugin() {
59
60
  PluginInfo(
60
61
  com.appsflyer.internal.platform_extension.Plugin.CAPACITOR,
61
62
  BuildConfig.VERSION_NAME
62
- //, mapOf("build_number" to BuildConfig.VERSION_CODE.toString())
63
+ //, mapOf("build_number" to BuildConfig.VERSION_CODE.toString())
63
64
  )
64
65
  )
65
66
  if (debug == true) {
@@ -86,18 +87,15 @@ class AppsFlyerPlugin : Plugin() {
86
87
  subscribeForDeepLink(getDeepLinkListener())
87
88
  }
88
89
  }
89
- start(activity ?: context.applicationContext, null, object : AppsFlyerRequestListener {
90
- override fun onSuccess() {
91
- val ret = JSObject()
92
- ret.put("res", "ok")
93
- call.resolve(ret)
94
- }
95
90
 
96
- override fun onError(p0: Int, p1: String) {
97
- call.reject(p1, p0.toString())
91
+ if (manualStart == false) {
92
+ startSDK(call)
93
+ } else {
94
+ val result = JSObject().apply {
95
+ put("res", "SDK initiated successfully. SDK has NOT been started yet")
98
96
  }
99
-
100
- })
97
+ call.resolve(result)
98
+ }
101
99
  }
102
100
 
103
101
  }
@@ -284,6 +282,23 @@ class AppsFlyerPlugin : Plugin() {
284
282
  }
285
283
  }
286
284
 
285
+ @PluginMethod
286
+ fun startSDK(call: PluginCall) {
287
+ AppsFlyerLib.getInstance()
288
+ .start(activity ?: context.applicationContext, null, object : AppsFlyerRequestListener {
289
+ override fun onSuccess() {
290
+ val result = JSObject().apply {
291
+ put("res", "success")
292
+ }
293
+ call.resolve(result)
294
+ }
295
+
296
+ override fun onError(errCode: Int, msg: String) {
297
+ call.reject("Error Code: $errCode, Message: $msg")
298
+ }
299
+ })
300
+ }
301
+
287
302
  @PluginMethod
288
303
  fun disableSKAdNetwork(call: PluginCall) {
289
304
  call.unavailable()
@@ -517,6 +532,35 @@ class AppsFlyerPlugin : Plugin() {
517
532
 
518
533
  }
519
534
 
535
+ @PluginMethod(returnType = PluginMethod.RETURN_NONE)
536
+ fun enableTCFDataCollection(call: PluginCall) {
537
+ val shouldEnable = call.getBoolean(AF_ENABLE_TCF_DATA_COLLECTION)
538
+ if (shouldEnable != null) {
539
+ AppsFlyerLib.getInstance().enableTCFDataCollection(shouldEnable)
540
+ } else {
541
+ call.reject("Missing boolean value $AF_ENABLE_TCF_DATA_COLLECTION")
542
+ }
543
+ }
544
+
545
+ @PluginMethod(returnType = PluginMethod.RETURN_NONE)
546
+ fun setConsentData(call: PluginCall) {
547
+ val consentData = call.getObject("data") ?: return call.reject("Missing consent data")
548
+
549
+ val isUserSubjectToGDPR = consentData.optBoolean(AF_IS_SUBJECTED_TO_GDPR)
550
+ val hasConsentForDataUsage = consentData.optBoolean(AF_CONSENT_FOR_DATA_USAGE)
551
+ val hasConsentForAdsPersonalization = consentData.optBoolean(AF_CONSENT_FOR_ADS_PERSONALIZATION)
552
+
553
+ val consentObject = if (isUserSubjectToGDPR) {
554
+ AppsFlyerConsent.forGDPRUser(hasConsentForDataUsage, hasConsentForAdsPersonalization)
555
+ } else {
556
+ AppsFlyerConsent.forNonGDPRUser()
557
+ }
558
+
559
+ AppsFlyerLib.getInstance().setConsentData(consentObject)
560
+
561
+ call.resolve()
562
+ }
563
+
520
564
  private fun getDeepLinkListener(): DeepLinkListener {
521
565
  return DeepLinkListener {
522
566
  if (udl == true) {
@@ -10,6 +10,7 @@ export interface AFInit {
10
10
  useReceiptValidationSandbox?: boolean;
11
11
  minTimeBetweenSessions?: number;
12
12
  deepLinkTimeout?: number;
13
+ manualStart?: boolean;
13
14
  }
14
15
  export interface AFEvent {
15
16
  eventName?: string;
@@ -147,3 +148,27 @@ export interface AFAppendToDeepLink {
147
148
  contains: string;
148
149
  parameters: StringMap;
149
150
  }
151
+ export interface AFEnableTCFDataCollection {
152
+ shouldEnableTCFDataCollection: boolean;
153
+ }
154
+ export interface IAppsFlyerConsent {
155
+ isUserSubjectToGDPR: boolean;
156
+ hasConsentForDataUsage?: boolean;
157
+ hasConsentForAdsPersonalization?: boolean;
158
+ }
159
+ declare class AppsFlyerConsentClass implements IAppsFlyerConsent {
160
+ isUserSubjectToGDPR: boolean;
161
+ hasConsentForDataUsage?: boolean;
162
+ hasConsentForAdsPersonalization?: boolean;
163
+ private constructor();
164
+ static forGDPRUser(hasConsentForDataUsage: boolean, hasConsentForAdsPersonalization: boolean): IAppsFlyerConsent;
165
+ static forNonGDPRUser(): IAppsFlyerConsent;
166
+ }
167
+ export declare const AppsFlyerConsent: {
168
+ forGDPRUser: typeof AppsFlyerConsentClass.forGDPRUser;
169
+ forNonGDPRUser: typeof AppsFlyerConsentClass.forNonGDPRUser;
170
+ };
171
+ export interface AFConsentData {
172
+ data: IAppsFlyerConsent;
173
+ }
174
+ export {};
@@ -1,2 +1,18 @@
1
- export {};
1
+ class AppsFlyerConsentClass {
2
+ constructor(isUserSubjectToGDPR, hasConsentForDataUsage, hasConsentForAdsPersonalization) {
3
+ this.isUserSubjectToGDPR = isUserSubjectToGDPR;
4
+ this.hasConsentForDataUsage = hasConsentForDataUsage;
5
+ this.hasConsentForAdsPersonalization = hasConsentForAdsPersonalization;
6
+ }
7
+ static forGDPRUser(hasConsentForDataUsage, hasConsentForAdsPersonalization) {
8
+ return new AppsFlyerConsentClass(true, hasConsentForDataUsage, hasConsentForAdsPersonalization);
9
+ }
10
+ static forNonGDPRUser() {
11
+ return new AppsFlyerConsentClass(false);
12
+ }
13
+ }
14
+ export const AppsFlyerConsent = {
15
+ forGDPRUser: AppsFlyerConsentClass.forGDPRUser,
16
+ forNonGDPRUser: AppsFlyerConsentClass.forNonGDPRUser
17
+ };
2
18
  //# sourceMappingURL=appsflyer_interfaces.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"appsflyer_interfaces.js","sourceRoot":"","sources":["../../src/appsflyer_interfaces.ts"],"names":[],"mappings":""}
1
+ {"version":3,"file":"appsflyer_interfaces.js","sourceRoot":"","sources":["../../src/appsflyer_interfaces.ts"],"names":[],"mappings":"AA0HA,MAAM,qBAAqB;IAKvB,YAAoB,mBAA4B,EAAE,sBAAgC,EAAE,+BAAyC;QACzH,IAAI,CAAC,mBAAmB,GAAG,mBAAmB,CAAC;QAC/C,IAAI,CAAC,sBAAsB,GAAG,sBAAsB,CAAC;QACrD,IAAI,CAAC,+BAA+B,GAAG,+BAA+B,CAAC;IAC3E,CAAC;IAED,MAAM,CAAC,WAAW,CAAC,sBAA+B,EAAE,+BAAwC;QACxF,OAAO,IAAI,qBAAqB,CAAC,IAAI,EAAE,sBAAsB,EAAE,+BAA+B,CAAC,CAAC;IACpG,CAAC;IAED,MAAM,CAAC,cAAc;QACjB,OAAO,IAAI,qBAAqB,CAAC,KAAK,CAAC,CAAC;IAC5C,CAAC;CACJ;AAED,MAAM,CAAC,MAAM,gBAAgB,GAAG;IAC5B,WAAW,EAAE,qBAAqB,CAAC,WAAW;IAC9C,cAAc,EAAE,qBAAqB,CAAC,cAAc;CACvD,CAAC"}
@@ -1,6 +1,6 @@
1
1
  import type { PluginListenerHandle } from "@capacitor/core";
2
2
  import type { AFConstants } from "./Appsflyer_constants";
3
- import type { AFAndroidInAppPurchase, AFAnonymizeUser, AFAppendToDeepLink, AFCuid, AFCurrency, AFData, AFDisable, AFEvent, AFFbDAL, AFFilters, AFHost, AFInit, AFIosInAppPurchase, AFIsStopped, AFLink, AFLinkGenerator, AFOnelinkDomain, AFOnelinkID, AFPath, AFPushPayload, AFRes, AFStop, AFUid, AFUninstall, AFUrls, AFLanguage, OnAppOpenAttribution, OnConversionDataResult, OnDeepLink, AFPromotion, AFEmails, AFLatLng, AFPhone, AFPartnerData, AFLogInvite } from "./appsflyer_interfaces";
3
+ import type { AFAndroidInAppPurchase, AFAnonymizeUser, AFAppendToDeepLink, AFCuid, AFCurrency, AFData, AFDisable, AFEvent, AFFbDAL, AFFilters, AFHost, AFInit, AFIosInAppPurchase, AFIsStopped, AFLink, AFLinkGenerator, AFOnelinkDomain, AFOnelinkID, AFPath, AFPushPayload, AFRes, AFStop, AFUid, AFUninstall, AFUrls, AFLanguage, OnAppOpenAttribution, OnConversionDataResult, OnDeepLink, AFPromotion, AFEmails, AFLatLng, AFPhone, AFPartnerData, AFLogInvite, AFEnableTCFDataCollection, AFConsentData } from "./appsflyer_interfaces";
4
4
  export interface AppsFlyerPlugin {
5
5
  addListener(eventName: AFConstants.CONVERSION_CALLBACK, listenerFunc: (event: OnConversionDataResult) => void): PluginListenerHandle;
6
6
  addListener(eventName: AFConstants.OAOA_CALLBACK, listenerFunc: (event: OnAppOpenAttribution) => void): PluginListenerHandle;
@@ -9,6 +9,10 @@ export interface AppsFlyerPlugin {
9
9
  * Use this method to initialize and start AppsFlyer SDK. This API should be called as soon as the app launched.
10
10
  */
11
11
  initSDK(options: AFInit): Promise<AFRes>;
12
+ /**
13
+ * Use this method to start AppsFlyer SDK, only on manual start mode.
14
+ */
15
+ startSDK(): Promise<AFRes>;
12
16
  /**
13
17
  * Log an in-app event.
14
18
  *
@@ -159,4 +163,15 @@ export interface AppsFlyerPlugin {
159
163
  * @param disable Defaults to false
160
164
  */
161
165
  setDisableNetworkData(disable: AFDisable): Promise<void>;
166
+ /**
167
+ * Use to opt-in/out the automatic collection of consent data, for users who use a CMP.
168
+ * Flag value will be persisted between app sessions.
169
+ */
170
+ enableTCFDataCollection(shouldEnableTCFDataCollection: AFEnableTCFDataCollection): Promise<void>;
171
+ /**
172
+ * Use to set user consent data manualy.
173
+ * if your app doesn't use a CMP compatible with TCF v2.2, use the following method to manualy provide the consent data directly to the SDK.
174
+ * @param data: AppsFlyerConsent object.
175
+ */
176
+ setConsentData(data: AFConsentData): Promise<void>;
162
177
  }
@@ -15,7 +15,26 @@ exports.AFConstants = void 0;
15
15
  AFConstants["UDL_CALLBACK"] = "udl_callback";
16
16
  })(exports.AFConstants || (exports.AFConstants = {}));
17
17
 
18
+ class AppsFlyerConsentClass {
19
+ constructor(isUserSubjectToGDPR, hasConsentForDataUsage, hasConsentForAdsPersonalization) {
20
+ this.isUserSubjectToGDPR = isUserSubjectToGDPR;
21
+ this.hasConsentForDataUsage = hasConsentForDataUsage;
22
+ this.hasConsentForAdsPersonalization = hasConsentForAdsPersonalization;
23
+ }
24
+ static forGDPRUser(hasConsentForDataUsage, hasConsentForAdsPersonalization) {
25
+ return new AppsFlyerConsentClass(true, hasConsentForDataUsage, hasConsentForAdsPersonalization);
26
+ }
27
+ static forNonGDPRUser() {
28
+ return new AppsFlyerConsentClass(false);
29
+ }
30
+ }
31
+ const AppsFlyerConsent = {
32
+ forGDPRUser: AppsFlyerConsentClass.forGDPRUser,
33
+ forNonGDPRUser: AppsFlyerConsentClass.forNonGDPRUser
34
+ };
35
+
18
36
  const AppsFlyer = core.registerPlugin('AppsFlyerPlugin', {});
19
37
 
20
38
  exports.AppsFlyer = AppsFlyer;
39
+ exports.AppsFlyerConsent = AppsFlyerConsent;
21
40
  //# sourceMappingURL=plugin.cjs.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"plugin.cjs.js","sources":["esm/Appsflyer_constants.js","esm/index.js"],"sourcesContent":["export var AFConstants;\n(function (AFConstants) {\n AFConstants[\"onConversionDataSuccess\"] = \"onConversionDataSuccess\";\n AFConstants[\"onConversionDataFail\"] = \"onConversionDataFail\";\n AFConstants[\"onAppOpenAttribution\"] = \"onAppOpenAttribution\";\n AFConstants[\"onAttributionFailure\"] = \"onAttributionFailure\";\n AFConstants[\"CONVERSION_CALLBACK\"] = \"conversion_callback\";\n AFConstants[\"OAOA_CALLBACK\"] = \"oaoa_callback\";\n AFConstants[\"UDL_CALLBACK\"] = \"udl_callback\";\n})(AFConstants || (AFConstants = {}));\n//# sourceMappingURL=Appsflyer_constants.js.map","import { registerPlugin } from '@capacitor/core';\nconst AppsFlyer = registerPlugin('AppsFlyerPlugin', {});\nexport * from './definitions';\nexport * from './Appsflyer_constants';\nexport * from './appsflyer_interfaces';\nexport { AppsFlyer };\n//# sourceMappingURL=index.js.map"],"names":["AFConstants","registerPlugin"],"mappings":";;;;;;AAAWA,6BAAY;AACvB,CAAC,UAAU,WAAW,EAAE;AACxB,IAAI,WAAW,CAAC,yBAAyB,CAAC,GAAG,yBAAyB,CAAC;AACvE,IAAI,WAAW,CAAC,sBAAsB,CAAC,GAAG,sBAAsB,CAAC;AACjE,IAAI,WAAW,CAAC,sBAAsB,CAAC,GAAG,sBAAsB,CAAC;AACjE,IAAI,WAAW,CAAC,sBAAsB,CAAC,GAAG,sBAAsB,CAAC;AACjE,IAAI,WAAW,CAAC,qBAAqB,CAAC,GAAG,qBAAqB,CAAC;AAC/D,IAAI,WAAW,CAAC,eAAe,CAAC,GAAG,eAAe,CAAC;AACnD,IAAI,WAAW,CAAC,cAAc,CAAC,GAAG,cAAc,CAAC;AACjD,CAAC,EAAEA,mBAAW,KAAKA,mBAAW,GAAG,EAAE,CAAC,CAAC;;ACRhC,MAAC,SAAS,GAAGC,mBAAc,CAAC,iBAAiB,EAAE,EAAE;;;;"}
1
+ {"version":3,"file":"plugin.cjs.js","sources":["esm/Appsflyer_constants.js","esm/appsflyer_interfaces.js","esm/index.js"],"sourcesContent":["export var AFConstants;\n(function (AFConstants) {\n AFConstants[\"onConversionDataSuccess\"] = \"onConversionDataSuccess\";\n AFConstants[\"onConversionDataFail\"] = \"onConversionDataFail\";\n AFConstants[\"onAppOpenAttribution\"] = \"onAppOpenAttribution\";\n AFConstants[\"onAttributionFailure\"] = \"onAttributionFailure\";\n AFConstants[\"CONVERSION_CALLBACK\"] = \"conversion_callback\";\n AFConstants[\"OAOA_CALLBACK\"] = \"oaoa_callback\";\n AFConstants[\"UDL_CALLBACK\"] = \"udl_callback\";\n})(AFConstants || (AFConstants = {}));\n//# sourceMappingURL=Appsflyer_constants.js.map","class AppsFlyerConsentClass {\n constructor(isUserSubjectToGDPR, hasConsentForDataUsage, hasConsentForAdsPersonalization) {\n this.isUserSubjectToGDPR = isUserSubjectToGDPR;\n this.hasConsentForDataUsage = hasConsentForDataUsage;\n this.hasConsentForAdsPersonalization = hasConsentForAdsPersonalization;\n }\n static forGDPRUser(hasConsentForDataUsage, hasConsentForAdsPersonalization) {\n return new AppsFlyerConsentClass(true, hasConsentForDataUsage, hasConsentForAdsPersonalization);\n }\n static forNonGDPRUser() {\n return new AppsFlyerConsentClass(false);\n }\n}\nexport const AppsFlyerConsent = {\n forGDPRUser: AppsFlyerConsentClass.forGDPRUser,\n forNonGDPRUser: AppsFlyerConsentClass.forNonGDPRUser\n};\n//# sourceMappingURL=appsflyer_interfaces.js.map","import { registerPlugin } from '@capacitor/core';\nconst AppsFlyer = registerPlugin('AppsFlyerPlugin', {});\nexport * from './definitions';\nexport * from './Appsflyer_constants';\nexport * from './appsflyer_interfaces';\nexport { AppsFlyer };\n//# sourceMappingURL=index.js.map"],"names":["AFConstants","registerPlugin"],"mappings":";;;;;;AAAWA,6BAAY;AACvB,CAAC,UAAU,WAAW,EAAE;AACxB,IAAI,WAAW,CAAC,yBAAyB,CAAC,GAAG,yBAAyB,CAAC;AACvE,IAAI,WAAW,CAAC,sBAAsB,CAAC,GAAG,sBAAsB,CAAC;AACjE,IAAI,WAAW,CAAC,sBAAsB,CAAC,GAAG,sBAAsB,CAAC;AACjE,IAAI,WAAW,CAAC,sBAAsB,CAAC,GAAG,sBAAsB,CAAC;AACjE,IAAI,WAAW,CAAC,qBAAqB,CAAC,GAAG,qBAAqB,CAAC;AAC/D,IAAI,WAAW,CAAC,eAAe,CAAC,GAAG,eAAe,CAAC;AACnD,IAAI,WAAW,CAAC,cAAc,CAAC,GAAG,cAAc,CAAC;AACjD,CAAC,EAAEA,mBAAW,KAAKA,mBAAW,GAAG,EAAE,CAAC,CAAC;;ACTrC,MAAM,qBAAqB,CAAC;AAC5B,IAAI,WAAW,CAAC,mBAAmB,EAAE,sBAAsB,EAAE,+BAA+B,EAAE;AAC9F,QAAQ,IAAI,CAAC,mBAAmB,GAAG,mBAAmB,CAAC;AACvD,QAAQ,IAAI,CAAC,sBAAsB,GAAG,sBAAsB,CAAC;AAC7D,QAAQ,IAAI,CAAC,+BAA+B,GAAG,+BAA+B,CAAC;AAC/E,KAAK;AACL,IAAI,OAAO,WAAW,CAAC,sBAAsB,EAAE,+BAA+B,EAAE;AAChF,QAAQ,OAAO,IAAI,qBAAqB,CAAC,IAAI,EAAE,sBAAsB,EAAE,+BAA+B,CAAC,CAAC;AACxG,KAAK;AACL,IAAI,OAAO,cAAc,GAAG;AAC5B,QAAQ,OAAO,IAAI,qBAAqB,CAAC,KAAK,CAAC,CAAC;AAChD,KAAK;AACL,CAAC;AACW,MAAC,gBAAgB,GAAG;AAChC,IAAI,WAAW,EAAE,qBAAqB,CAAC,WAAW;AAClD,IAAI,cAAc,EAAE,qBAAqB,CAAC,cAAc;AACxD;;ACfK,MAAC,SAAS,GAAGC,mBAAc,CAAC,iBAAiB,EAAE,EAAE;;;;;"}
package/dist/plugin.js CHANGED
@@ -12,9 +12,28 @@ var AppsFlyerCapacitorPlugin = (function (exports, core) {
12
12
  AFConstants["UDL_CALLBACK"] = "udl_callback";
13
13
  })(exports.AFConstants || (exports.AFConstants = {}));
14
14
 
15
+ class AppsFlyerConsentClass {
16
+ constructor(isUserSubjectToGDPR, hasConsentForDataUsage, hasConsentForAdsPersonalization) {
17
+ this.isUserSubjectToGDPR = isUserSubjectToGDPR;
18
+ this.hasConsentForDataUsage = hasConsentForDataUsage;
19
+ this.hasConsentForAdsPersonalization = hasConsentForAdsPersonalization;
20
+ }
21
+ static forGDPRUser(hasConsentForDataUsage, hasConsentForAdsPersonalization) {
22
+ return new AppsFlyerConsentClass(true, hasConsentForDataUsage, hasConsentForAdsPersonalization);
23
+ }
24
+ static forNonGDPRUser() {
25
+ return new AppsFlyerConsentClass(false);
26
+ }
27
+ }
28
+ const AppsFlyerConsent = {
29
+ forGDPRUser: AppsFlyerConsentClass.forGDPRUser,
30
+ forNonGDPRUser: AppsFlyerConsentClass.forNonGDPRUser
31
+ };
32
+
15
33
  const AppsFlyer = core.registerPlugin('AppsFlyerPlugin', {});
16
34
 
17
35
  exports.AppsFlyer = AppsFlyer;
36
+ exports.AppsFlyerConsent = AppsFlyerConsent;
18
37
 
19
38
  Object.defineProperty(exports, '__esModule', { value: true });
20
39
 
@@ -1 +1 @@
1
- {"version":3,"file":"plugin.js","sources":["esm/Appsflyer_constants.js","esm/index.js"],"sourcesContent":["export var AFConstants;\n(function (AFConstants) {\n AFConstants[\"onConversionDataSuccess\"] = \"onConversionDataSuccess\";\n AFConstants[\"onConversionDataFail\"] = \"onConversionDataFail\";\n AFConstants[\"onAppOpenAttribution\"] = \"onAppOpenAttribution\";\n AFConstants[\"onAttributionFailure\"] = \"onAttributionFailure\";\n AFConstants[\"CONVERSION_CALLBACK\"] = \"conversion_callback\";\n AFConstants[\"OAOA_CALLBACK\"] = \"oaoa_callback\";\n AFConstants[\"UDL_CALLBACK\"] = \"udl_callback\";\n})(AFConstants || (AFConstants = {}));\n//# sourceMappingURL=Appsflyer_constants.js.map","import { registerPlugin } from '@capacitor/core';\nconst AppsFlyer = registerPlugin('AppsFlyerPlugin', {});\nexport * from './definitions';\nexport * from './Appsflyer_constants';\nexport * from './appsflyer_interfaces';\nexport { AppsFlyer };\n//# sourceMappingURL=index.js.map"],"names":["AFConstants","registerPlugin"],"mappings":";;;AAAWA,iCAAY;IACvB,CAAC,UAAU,WAAW,EAAE;IACxB,IAAI,WAAW,CAAC,yBAAyB,CAAC,GAAG,yBAAyB,CAAC;IACvE,IAAI,WAAW,CAAC,sBAAsB,CAAC,GAAG,sBAAsB,CAAC;IACjE,IAAI,WAAW,CAAC,sBAAsB,CAAC,GAAG,sBAAsB,CAAC;IACjE,IAAI,WAAW,CAAC,sBAAsB,CAAC,GAAG,sBAAsB,CAAC;IACjE,IAAI,WAAW,CAAC,qBAAqB,CAAC,GAAG,qBAAqB,CAAC;IAC/D,IAAI,WAAW,CAAC,eAAe,CAAC,GAAG,eAAe,CAAC;IACnD,IAAI,WAAW,CAAC,cAAc,CAAC,GAAG,cAAc,CAAC;IACjD,CAAC,EAAEA,mBAAW,KAAKA,mBAAW,GAAG,EAAE,CAAC,CAAC;;ACRhC,UAAC,SAAS,GAAGC,mBAAc,CAAC,iBAAiB,EAAE,EAAE;;;;;;;;;;;;"}
1
+ {"version":3,"file":"plugin.js","sources":["esm/Appsflyer_constants.js","esm/appsflyer_interfaces.js","esm/index.js"],"sourcesContent":["export var AFConstants;\n(function (AFConstants) {\n AFConstants[\"onConversionDataSuccess\"] = \"onConversionDataSuccess\";\n AFConstants[\"onConversionDataFail\"] = \"onConversionDataFail\";\n AFConstants[\"onAppOpenAttribution\"] = \"onAppOpenAttribution\";\n AFConstants[\"onAttributionFailure\"] = \"onAttributionFailure\";\n AFConstants[\"CONVERSION_CALLBACK\"] = \"conversion_callback\";\n AFConstants[\"OAOA_CALLBACK\"] = \"oaoa_callback\";\n AFConstants[\"UDL_CALLBACK\"] = \"udl_callback\";\n})(AFConstants || (AFConstants = {}));\n//# sourceMappingURL=Appsflyer_constants.js.map","class AppsFlyerConsentClass {\n constructor(isUserSubjectToGDPR, hasConsentForDataUsage, hasConsentForAdsPersonalization) {\n this.isUserSubjectToGDPR = isUserSubjectToGDPR;\n this.hasConsentForDataUsage = hasConsentForDataUsage;\n this.hasConsentForAdsPersonalization = hasConsentForAdsPersonalization;\n }\n static forGDPRUser(hasConsentForDataUsage, hasConsentForAdsPersonalization) {\n return new AppsFlyerConsentClass(true, hasConsentForDataUsage, hasConsentForAdsPersonalization);\n }\n static forNonGDPRUser() {\n return new AppsFlyerConsentClass(false);\n }\n}\nexport const AppsFlyerConsent = {\n forGDPRUser: AppsFlyerConsentClass.forGDPRUser,\n forNonGDPRUser: AppsFlyerConsentClass.forNonGDPRUser\n};\n//# sourceMappingURL=appsflyer_interfaces.js.map","import { registerPlugin } from '@capacitor/core';\nconst AppsFlyer = registerPlugin('AppsFlyerPlugin', {});\nexport * from './definitions';\nexport * from './Appsflyer_constants';\nexport * from './appsflyer_interfaces';\nexport { AppsFlyer };\n//# sourceMappingURL=index.js.map"],"names":["AFConstants","registerPlugin"],"mappings":";;;AAAWA,iCAAY;IACvB,CAAC,UAAU,WAAW,EAAE;IACxB,IAAI,WAAW,CAAC,yBAAyB,CAAC,GAAG,yBAAyB,CAAC;IACvE,IAAI,WAAW,CAAC,sBAAsB,CAAC,GAAG,sBAAsB,CAAC;IACjE,IAAI,WAAW,CAAC,sBAAsB,CAAC,GAAG,sBAAsB,CAAC;IACjE,IAAI,WAAW,CAAC,sBAAsB,CAAC,GAAG,sBAAsB,CAAC;IACjE,IAAI,WAAW,CAAC,qBAAqB,CAAC,GAAG,qBAAqB,CAAC;IAC/D,IAAI,WAAW,CAAC,eAAe,CAAC,GAAG,eAAe,CAAC;IACnD,IAAI,WAAW,CAAC,cAAc,CAAC,GAAG,cAAc,CAAC;IACjD,CAAC,EAAEA,mBAAW,KAAKA,mBAAW,GAAG,EAAE,CAAC,CAAC;;ICTrC,MAAM,qBAAqB,CAAC;IAC5B,IAAI,WAAW,CAAC,mBAAmB,EAAE,sBAAsB,EAAE,+BAA+B,EAAE;IAC9F,QAAQ,IAAI,CAAC,mBAAmB,GAAG,mBAAmB,CAAC;IACvD,QAAQ,IAAI,CAAC,sBAAsB,GAAG,sBAAsB,CAAC;IAC7D,QAAQ,IAAI,CAAC,+BAA+B,GAAG,+BAA+B,CAAC;IAC/E,KAAK;IACL,IAAI,OAAO,WAAW,CAAC,sBAAsB,EAAE,+BAA+B,EAAE;IAChF,QAAQ,OAAO,IAAI,qBAAqB,CAAC,IAAI,EAAE,sBAAsB,EAAE,+BAA+B,CAAC,CAAC;IACxG,KAAK;IACL,IAAI,OAAO,cAAc,GAAG;IAC5B,QAAQ,OAAO,IAAI,qBAAqB,CAAC,KAAK,CAAC,CAAC;IAChD,KAAK;IACL,CAAC;AACW,UAAC,gBAAgB,GAAG;IAChC,IAAI,WAAW,EAAE,qBAAqB,CAAC,WAAW;IAClD,IAAI,cAAc,EAAE,qBAAqB,CAAC,cAAc;IACxD;;ACfK,UAAC,SAAS,GAAGC,mBAAc,CAAC,iBAAiB,EAAE,EAAE;;;;;;;;;;;;;"}
@@ -29,7 +29,7 @@ class AppsFlyerConstants {
29
29
  static let AF_ONELINK_ID = "onelinkID"
30
30
  static let AF_ONELINK_DOMAIN = "domains"
31
31
  static let AF_DEEPLINK_URLS = "urls"
32
- static let AF_PATH = "path"
32
+ static let AF_PATH = "path"
33
33
  static let AF_UID = "uid"
34
34
  static let AF_ANONYMIZE_USER = "anonymizeUser"
35
35
  static let AF_STOP = "stop"
@@ -68,5 +68,9 @@ class AppsFlyerConstants {
68
68
  static let AF_EVENT_PARAMETERS = "eventParameters"
69
69
  static let AF_PARTNER_ID = "partnerId"
70
70
  static let AF_DATA = "data"
71
-
71
+ static let AF_ENABLE_TCF_DATA_COLLECTION = "shouldEnableTCFDataCollection"
72
+ static let AF_MANUAL_START = "manualStart"
73
+ static let AF_IS_SUBJECTED_TO_DGPR = "isUserSubjectToGDPR"
74
+ static let AF_CONSENT_FOR_DATA_USAGE = "hasConsentForDataUsage"
75
+ static let AF_CONSENT_FOR_ADS_PERSONALIZATION = "hasConsentForAdsPersonalization"
72
76
  }
@@ -38,6 +38,10 @@ CAP_PLUGIN(AppsFlyerPlugin, "AppsFlyerPlugin",
38
38
  CAP_PLUGIN_METHOD(setPartnerData, CAPPluginReturnPromise);
39
39
  CAP_PLUGIN_METHOD(logInvite, CAPPluginReturnPromise);
40
40
  CAP_PLUGIN_METHOD(setSharingFilterForPartners, CAPPluginReturnPromise);
41
+ CAP_PLUGIN_METHOD(enableTCFDataCollection, CAPPluginReturnNone);
42
+ CAP_PLUGIN_METHOD(setConsentData, CAPPluginReturnNone);
43
+ CAP_PLUGIN_METHOD(startSDK, CAPPluginReturnPromise);
44
+
41
45
 
42
46
 
43
47
 
@@ -5,7 +5,7 @@ import AppsFlyerLib
5
5
 
6
6
  @objc(AppsFlyerPlugin)
7
7
  public class AppsFlyerPlugin: CAPPlugin {
8
- private let APPSFLYER_PLUGIN_VERSION = "6.12.1"
8
+ private let APPSFLYER_PLUGIN_VERSION = "6.13.0-rc1"
9
9
  private var conversion = true
10
10
  private var oaoa = true
11
11
  private var udl = false
@@ -34,7 +34,8 @@ public class AppsFlyerPlugin: CAPPlugin {
34
34
 
35
35
  let debug = call.getBool(AppsFlyerConstants.AF_DEBUG, false)
36
36
  let sandbox = call.getBool(AppsFlyerConstants.AF_SANDBOX, false)
37
- let receiptSandbox = call.getBool(AppsFlyerConstants.AF_RECEIPT_SANDBOX , false)
37
+ let receiptSandbox = call.getBool(AppsFlyerConstants.AF_RECEIPT_SANDBOX, false)
38
+ let manualStart = call.getBool(AppsFlyerConstants.AF_MANUAL_START, false)
38
39
 
39
40
  conversion = call.getBool(AppsFlyerConstants.AF_CONVERSION_LISTENER, true)
40
41
  oaoa = call.getBool(AppsFlyerConstants.AF_OAOA, true)
@@ -69,18 +70,25 @@ public class AppsFlyerPlugin: CAPPlugin {
69
70
  appsflyer.waitForATTUserAuthorization(timeoutInterval: Double(attInterval!))
70
71
  }
71
72
  #endif
73
+
74
+ if !manualStart {
75
+ startSDK(call)
76
+ } else {
77
+ call.resolve(["res": "SDK initiated successfully. SDK has NOT started yet"])
78
+ }
79
+ }
80
+
81
+ @objc func startSDK(_ call: CAPPluginCall) {
72
82
 
73
83
  NotificationCenter.default.addObserver(self, selector: #selector(sendLaunch), name: UIApplication.didBecomeActiveNotification, object: nil)
74
84
 
75
- appsflyer.start(completionHandler: { (dictionnary, error) in
76
- if (error != nil){
77
- call.reject(error!.localizedDescription)
78
- return
85
+ AppsFlyerLib.shared().start { dictionary, error in
86
+ if let error = error {
87
+ call.reject(error.localizedDescription)
79
88
  } else {
80
- call.resolve(["res":"ok"])
81
- return
89
+ call.resolve(["res": "success"])
82
90
  }
83
- })
91
+ }
84
92
  }
85
93
 
86
94
  @objc func logEvent(_ call: CAPPluginCall){
@@ -240,6 +248,36 @@ public class AppsFlyerPlugin: CAPPlugin {
240
248
  @objc func setDisableNetworkData(_ call: CAPPluginCall){
241
249
  call.unavailable("Android only method - has no effact on iOS apps")
242
250
  }
251
+
252
+ @objc func enableTCFDataCollection(_ call: CAPPluginCall){
253
+ guard let shouldEnableTCFDataCollection = call.getBool(AppsFlyerConstants.AF_ENABLE_TCF_DATA_COLLECTION) else {
254
+ call.reject("Missing boolean value shouldEnableTCFDataCollection")
255
+ return
256
+ }
257
+ AppsFlyerLib.shared().enableTCFDataCollection(shouldEnableTCFDataCollection)
258
+ }
259
+
260
+ @objc func setConsentData(_ call: CAPPluginCall) {
261
+ guard let consentData = call.getObject("data") else {
262
+ call.reject("Consent data is missing")
263
+ return
264
+ }
265
+
266
+ let isUserSubjectToGDPR = consentData[AppsFlyerConstants.AF_IS_SUBJECTED_TO_DGPR] as? Bool ?? false
267
+ let hasConsentForDataUsage = consentData[AppsFlyerConstants.AF_CONSENT_FOR_DATA_USAGE] as? Bool ?? false
268
+ let hasConsentForAdsPersonalization = consentData[AppsFlyerConstants.AF_CONSENT_FOR_ADS_PERSONALIZATION] as? Bool ?? false
269
+
270
+ let consentObject: AppsFlyerConsent
271
+ if isUserSubjectToGDPR {
272
+ consentObject = AppsFlyerConsent(forGDPRUserWithHasConsentForDataUsage: hasConsentForDataUsage, hasConsentForAdsPersonalization: hasConsentForAdsPersonalization)
273
+ } else {
274
+ consentObject = AppsFlyerConsent(nonGDPRUser: ())
275
+ }
276
+
277
+ AppsFlyerLib.shared().setConsentData(consentObject)
278
+
279
+ call.resolve()
280
+ }
243
281
 
244
282
  @objc func anonymizeUser(_ call: CAPPluginCall){
245
283
  guard let anonymize = call.getBool(AppsFlyerConstants.AF_ANONYMIZE_USER) else{
package/package.json CHANGED
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "name": "appsflyer-capacitor-plugin",
3
- "version": "6.12.1",
4
- "iosSdkVersion": "6.12.1",
5
- "androidSdkVersion": "6.12.1",
6
- "buildNumber": "10",
3
+ "version": "6.13.0-rc1",
4
+ "iosSdkVersion": "6.13.0",
5
+ "androidSdkVersion": "6.13.0",
6
+ "buildNumber": "82",
7
7
  "description": "AppsFlyer SDK plugin for Capacitor",
8
8
  "main": "dist/plugin.cjs.js",
9
9
  "module": "dist/esm/index.js",
@@ -10,7 +10,7 @@ export interface AFInit{
10
10
  useReceiptValidationSandbox?: boolean;
11
11
  minTimeBetweenSessions?: number
12
12
  deepLinkTimeout?: number
13
-
13
+ manualStart?: boolean;
14
14
  }
15
15
 
16
16
  export interface AFEvent{
@@ -112,3 +112,39 @@ export interface AFAppendToDeepLink{contains: string;
112
112
  parameters: StringMap;
113
113
  }
114
114
 
115
+ export interface AFEnableTCFDataCollection { shouldEnableTCFDataCollection: boolean }
116
+
117
+ export interface IAppsFlyerConsent {
118
+ isUserSubjectToGDPR: boolean,
119
+ hasConsentForDataUsage?: boolean,
120
+ hasConsentForAdsPersonalization?: boolean
121
+ }
122
+
123
+ class AppsFlyerConsentClass implements IAppsFlyerConsent {
124
+ public isUserSubjectToGDPR: boolean;
125
+ public hasConsentForDataUsage?: boolean;
126
+ public hasConsentForAdsPersonalization?: boolean;
127
+
128
+ private constructor(isUserSubjectToGDPR: boolean, hasConsentForDataUsage?: boolean, hasConsentForAdsPersonalization?: boolean) {
129
+ this.isUserSubjectToGDPR = isUserSubjectToGDPR;
130
+ this.hasConsentForDataUsage = hasConsentForDataUsage;
131
+ this.hasConsentForAdsPersonalization = hasConsentForAdsPersonalization;
132
+ }
133
+
134
+ static forGDPRUser(hasConsentForDataUsage: boolean, hasConsentForAdsPersonalization: boolean): IAppsFlyerConsent {
135
+ return new AppsFlyerConsentClass(true, hasConsentForDataUsage, hasConsentForAdsPersonalization);
136
+ }
137
+
138
+ static forNonGDPRUser(): IAppsFlyerConsent {
139
+ return new AppsFlyerConsentClass(false);
140
+ }
141
+ }
142
+
143
+ export const AppsFlyerConsent = {
144
+ forGDPRUser: AppsFlyerConsentClass.forGDPRUser,
145
+ forNonGDPRUser: AppsFlyerConsentClass.forNonGDPRUser
146
+ };
147
+
148
+ export interface AFConsentData {
149
+ data: IAppsFlyerConsent
150
+ }
@@ -36,7 +36,10 @@ import type {
36
36
  AFLatLng,
37
37
  AFPhone,
38
38
  AFPartnerData,
39
- AFLogInvite
39
+ AFLogInvite,
40
+ AFEnableTCFDataCollection,
41
+ AFConsentData
42
+
40
43
  } from "./appsflyer_interfaces";
41
44
 
42
45
  export interface AppsFlyerPlugin {
@@ -63,6 +66,11 @@ export interface AppsFlyerPlugin {
63
66
  */
64
67
  initSDK(options: AFInit): Promise<AFRes>;
65
68
 
69
+ /**
70
+ * Use this method to start AppsFlyer SDK, only on manual start mode.
71
+ */
72
+ startSDK(): Promise<AFRes>;
73
+
66
74
  /**
67
75
  * Log an in-app event.
68
76
  *
@@ -246,5 +254,19 @@ export interface AppsFlyerPlugin {
246
254
  * @param disable Defaults to false
247
255
  */
248
256
  setDisableNetworkData(disable : AFDisable): Promise<void>;
257
+
258
+ /**
259
+ * Use to opt-in/out the automatic collection of consent data, for users who use a CMP.
260
+ * Flag value will be persisted between app sessions.
261
+ */
262
+ enableTCFDataCollection(shouldEnableTCFDataCollection: AFEnableTCFDataCollection): Promise<void>
263
+
264
+ /**
265
+ * Use to set user consent data manualy.
266
+ * if your app doesn't use a CMP compatible with TCF v2.2, use the following method to manualy provide the consent data directly to the SDK.
267
+ * @param data: AppsFlyerConsent object.
268
+ */
269
+ setConsentData(data : AFConsentData): Promise<void>
270
+
249
271
  }
250
272