appsflyer-capacitor-plugin 6.9.2 → 6.10.3-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.
@@ -1,7 +1,6 @@
1
1
  require 'json'
2
2
 
3
3
  package = JSON.parse(File.read(File.join(__dir__, 'package.json')))
4
-
5
4
  Pod::Spec.new do |s|
6
5
  s.name = 'AppsflyerCapacitorPlugin'
7
6
  s.version = package['version']
package/README.md CHANGED
@@ -14,8 +14,8 @@
14
14
 
15
15
  ### <a id="plugin-build-for"> This plugin is built for
16
16
 
17
- - Android AppsFlyer SDK **6.9.2️**
18
- - iOS AppsFlyer SDK **6.9.0**
17
+ - Android AppsFlyer SDK **6.10.3**
18
+ - iOS AppsFlyer SDK **6.10.1**
19
19
 
20
20
  ## <a id="breaking-changes"> ❗❗ Breaking changes when updating to v6.9.2❗❗
21
21
  Starting from v6.9.2, this plugin works only with Capacitor 4. </br>
@@ -1,8 +1,37 @@
1
+ // On top of your file import a JSON parser
2
+ import groovy.json.JsonSlurper
3
+
4
+ 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)
9
+ return packageJson
10
+ }
11
+ // Create an easy to use function
12
+ def getVersionFromNpm() {
13
+ // Return the version, you can get any value this way
14
+ return getPackageJson()["version"]
15
+ }
16
+
17
+ // Create an easy to use function
18
+ def getSDKVersionFromNpm() {
19
+ // Return the version, you can get any value this way
20
+ return getPackageJson()["androidSdkVersion"]
21
+ }
22
+ def getPluginBuildVersionFromNpm() {
23
+ // Return the version, you can get any value this way
24
+ return getPackageJson()["buildNumber"]
25
+ }
26
+
1
27
  ext {
2
28
  junitVersion = project.hasProperty('junitVersion') ? rootProject.ext.junitVersion : '4.13.2'
3
29
  androidxAppCompatVersion = project.hasProperty('androidxAppCompatVersion') ? rootProject.ext.androidxAppCompatVersion : '1.4.2'
4
30
  androidxJunitVersion = project.hasProperty('androidxJunitVersion') ? rootProject.ext.androidxJunitVersion : '1.1.3'
5
31
  androidxEspressoCoreVersion = project.hasProperty('androidxEspressoCoreVersion') ? rootProject.ext.androidxEspressoCoreVersion : '3.4.0'
32
+ af_sdk_version = getSDKVersionFromNpm()
33
+ plugin_version = getVersionFromNpm()
34
+ plugin_build_version = getPluginBuildVersionFromNpm()
6
35
  }
7
36
 
8
37
  buildscript {
@@ -14,7 +43,7 @@ buildscript {
14
43
  dependencies {
15
44
  classpath 'com.android.tools.build:gradle:7.2.2'
16
45
  classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
17
-
46
+ classpath 'org.codehaus.groovy:groovy-json:3.0.9'
18
47
  }
19
48
  }
20
49
 
@@ -26,8 +55,10 @@ android {
26
55
  defaultConfig {
27
56
  minSdkVersion project.hasProperty('minSdkVersion') ? rootProject.ext.minSdkVersion : 22
28
57
  targetSdkVersion project.hasProperty('targetSdkVersion') ? rootProject.ext.targetSdkVersion : 32
29
- versionCode 1
30
- versionName "1.0"
58
+ versionCode Integer.parseInt(plugin_build_version)
59
+ versionName "$plugin_version"
60
+ buildConfigField "int", "VERSION_CODE", plugin_build_version
61
+ buildConfigField "String", "VERSION_NAME", "\"$plugin_version\""
31
62
  testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
32
63
  }
33
64
  buildTypes {
@@ -60,11 +91,10 @@ dependencies {
60
91
  androidTestImplementation "androidx.test.ext:junit:$androidxJunitVersion"
61
92
  androidTestImplementation "androidx.test.espresso:espresso-core:$androidxEspressoCoreVersion"
62
93
  implementation "androidx.core:core-ktx:1.8.0"
63
- implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
94
+ implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
64
95
 
65
- implementation 'com.appsflyer:af-android-sdk:6.9.2'
96
+ implementation "com.appsflyer:af-android-sdk:$af_sdk_version"
66
97
  implementation "com.android.installreferrer:installreferrer:2.2"
67
98
 
68
99
 
69
-
70
100
  }
@@ -7,6 +7,7 @@ import com.appsflyer.*
7
7
  import com.appsflyer.attribution.AppsFlyerRequestListener
8
8
  import com.appsflyer.deeplink.DeepLinkListener
9
9
  import com.appsflyer.deeplink.DeepLinkResult
10
+ import com.appsflyer.internal.platform_extension.PluginInfo
10
11
  import com.appsflyer.share.CrossPromotionHelper
11
12
  import com.appsflyer.share.ShareInviteHelper
12
13
  import com.getcapacitor.JSObject
@@ -53,6 +54,13 @@ class AppsFlyerPlugin : Plugin() {
53
54
  val timeout = call.getInt(AF_DEEP_LINK_TIME_OUT)?.toLong()
54
55
 
55
56
  AppsFlyerLib.getInstance().apply {
57
+ setPluginInfo(
58
+ PluginInfo(
59
+ com.appsflyer.internal.platform_extension.Plugin.CAPACITOR,
60
+ BuildConfig.VERSION_NAME
61
+ //, mapOf("build_number" to BuildConfig.VERSION_CODE.toString())
62
+ )
63
+ )
56
64
  if (debug == true) {
57
65
  setDebugLog(true)
58
66
  }
@@ -578,5 +586,3 @@ class AppsFlyerPlugin : Plugin() {
578
586
  }
579
587
  }
580
588
  }
581
-
582
-
@@ -5,604 +5,605 @@ import AppsFlyerLib
5
5
 
6
6
  @objc(AppsFlyerPlugin)
7
7
  public class AppsFlyerPlugin: CAPPlugin {
8
- private var conversion = true
9
- private var oaoa = true
10
- private var udl = false
11
-
12
- override public func load() {
8
+ private let APPSFLYER_PLUGIN_VERSION = "6.10.3-rc1"
9
+ private var conversion = true
10
+ private var oaoa = true
11
+ private var udl = false
13
12
 
14
- NotificationCenter.default.addObserver(self, selector: #selector(self.handleUrlOpened(notification:)), name: Notification.Name.capacitorOpenURL, object: nil)
15
- NotificationCenter.default.addObserver(self, selector: #selector(self.handleUniversalLink(notification:)), name: Notification.Name.capacitorOpenUniversalLink, object: nil)
13
+ override public func load() {
14
+
15
+ NotificationCenter.default.addObserver(self, selector: #selector(self.handleUrlOpened(notification:)), name: Notification.Name.capacitorOpenURL, object: nil)
16
+ NotificationCenter.default.addObserver(self, selector: #selector(self.handleUniversalLink(notification:)), name: Notification.Name.capacitorOpenUniversalLink, object: nil)
17
+
18
+ }
19
+
20
+
21
+ @objc func initSDK(_ call: CAPPluginCall){
22
+ let appsflyer = AppsFlyerLib.shared()
23
+
24
+ appsflyer.setPluginInfo(plugin: .capacitor, version: APPSFLYER_PLUGIN_VERSION, additionalParams: nil)
25
+ guard let devKey = call.getString(AppsFlyerConstants.AF_DEV_KEY) else{
26
+ call.reject("devkey is missing")
27
+ return
28
+ }
29
+ guard let appID = call.getString(AppsFlyerConstants.AF_APP_ID) else{
30
+ call.reject("appID is missing")
31
+ return
32
+ }
33
+ let attInterval = call.getInt(AppsFlyerConstants.AF_ATT)
34
+
35
+ let debug = call.getBool(AppsFlyerConstants.AF_DEBUG, false)
36
+ let sandbox = call.getBool(AppsFlyerConstants.AF_SANDBOX, false)
37
+ let receiptSandbox = call.getBool(AppsFlyerConstants.AF_RECEIPT_SANDBOX , false)
38
+
39
+ conversion = call.getBool(AppsFlyerConstants.AF_CONVERSION_LISTENER, true)
40
+ oaoa = call.getBool(AppsFlyerConstants.AF_OAOA, true)
41
+ udl = call.getBool(AppsFlyerConstants.AF_UDL, false)
42
+
43
+ appsflyer.isDebug = debug
44
+ appsflyer.appsFlyerDevKey = devKey
45
+ appsflyer.appleAppID = appID
46
+ appsflyer.useUninstallSandbox = sandbox
47
+ appsflyer.useReceiptValidationSandbox = receiptSandbox
48
+
49
+ if let minTime = call.getInt(AppsFlyerConstants.AF_MIN_TIME){
50
+ appsflyer.minTimeBetweenSessions = UInt(minTime)
51
+ }
52
+
53
+ if let timeout = call.getInt(AppsFlyerConstants.AF_DEEP_LINK_TIME_OUT){
54
+ appsflyer.deepLinkTimeout = UInt(timeout)
55
+ }
56
+
57
+ if conversion || oaoa {
58
+ appsflyer.delegate = self
59
+ }
60
+
61
+ if udl {
62
+ appsflyer.deepLinkDelegate = self
63
+ }
64
+
65
+ reportBridgeReady()
66
+
67
+ #if !AFSDK_NO_IDFA
68
+ if attInterval != nil {
69
+ appsflyer.waitForATTUserAuthorization(timeoutInterval: Double(attInterval!))
70
+ }
71
+ #endif
72
+
73
+ NotificationCenter.default.addObserver(self, selector: #selector(sendLaunch), name: UIApplication.didBecomeActiveNotification, object: nil)
74
+
75
+ appsflyer.start(completionHandler: { (dictionnary, error) in
76
+ if (error != nil){
77
+ call.reject(error!.localizedDescription)
78
+ return
79
+ } else {
80
+ call.resolve(["res":"ok"])
81
+ return
82
+ }
83
+ })
84
+ }
85
+
86
+ @objc func logEvent(_ call: CAPPluginCall){
87
+ guard let eventName = call.getString(AppsFlyerConstants.AF_EVENT_NAME) else{
88
+ call.reject("missing event name")
89
+ return
90
+ }
91
+ let eventValue = call.getObject(AppsFlyerConstants.AF_EVENT_VALUE)
92
+
93
+ AppsFlyerLib.shared().logEvent(name: eventName, values: eventValue) { (response: [String : Any]?, error: Error?) in
94
+ if let response = response {
95
+ call.resolve(["res":response])
96
+ }
97
+ if let error = error {
98
+ call.reject(error.localizedDescription, nil, error)
99
+ }
100
+ }
101
+ }
102
+
103
+ @objc func setCustomerUserId(_ call: CAPPluginCall){
104
+ guard let cuid = call.getString(AppsFlyerConstants.AF_CUID) else {
105
+ call.reject("Invalid Customer User ID")
106
+ return
107
+ }
108
+ AppsFlyerLib.shared().customerUserID = cuid
109
+
110
+ }
111
+
112
+ @objc func setCurrencyCode(_ call: CAPPluginCall){
113
+ guard let code = call.getString(AppsFlyerConstants.AF_CURRENCY_CODE) else {
114
+ call.reject("Invalid Currency Code")
115
+ return
116
+ }
117
+ AppsFlyerLib.shared().currencyCode = code
118
+
119
+
120
+ }
121
+
122
+ @objc func updateServerUninstallToken(_ call: CAPPluginCall){
123
+ guard let token = call.getString(AppsFlyerConstants.AF_TOKEN) else {
124
+ call.reject("Invalid device token")
125
+
126
+ return
127
+ }
128
+
129
+ guard let deviceTokenData = token.hexadecimalToData else{
130
+ call.reject("Invalid device token")
131
+ return
132
+ }
133
+ AppsFlyerLib.shared().registerUninstall(deviceTokenData)
134
+ }
135
+
136
+ @objc func setAppInviteOneLink(_ call: CAPPluginCall){
137
+ guard let id = call.getString(AppsFlyerConstants.AF_ONELINK_ID) else {
138
+ call.reject("Onelink id is missing")
139
+ return
140
+ }
141
+ AppsFlyerLib.shared().appInviteOneLinkID = id
142
+
143
+ }
144
+
145
+ @objc func setOneLinkCustomDomain(_ call: CAPPluginCall){
146
+ guard let arr = call.getArray(AppsFlyerConstants.AF_ONELINK_DOMAIN) else {
147
+ call.reject("Domains are missing")
148
+ return
149
+ }
150
+ var domains :[String] = []
151
+ for dom in arr {
152
+ domains.append(dom as! String)
153
+ }
154
+ AppsFlyerLib.shared().oneLinkCustomDomains = domains
155
+
156
+ }
16
157
 
17
- }
18
-
19
-
20
- @objc func initSDK(_ call: CAPPluginCall){
21
- let appsflyer = AppsFlyerLib.shared()
22
- guard let devKey = call.getString(AppsFlyerConstants.AF_DEV_KEY) else{
23
- call.reject("devkey is missing")
24
- return
158
+ @objc func appendParametersToDeepLinkingURL(_ call: CAPPluginCall){
159
+ guard let contains = call.getString(AppsFlyerConstants.AF_CONTAINS) else {
160
+ return
161
+ }
162
+ guard let parameters = call.getObject(AppsFlyerConstants.AF_PARAMETERS) else {
163
+ return
164
+ }
165
+ var params: [String:String] = [:]
166
+ for (k,v) in parameters{
167
+ params[k] = (v as! String)
168
+ }
169
+ AppsFlyerLib.shared().appendParametersToDeeplinkURL(contains: contains, parameters:params )
170
+
25
171
  }
26
- guard let appID = call.getString(AppsFlyerConstants.AF_APP_ID) else{
27
- call.reject("appID is missing")
28
- return
172
+
173
+
174
+ @objc func setResolveDeepLinkURLs(_ call: CAPPluginCall){
175
+ guard let arr = call.getArray(AppsFlyerConstants.AF_DEEPLINK_URLS) else {
176
+ call.reject("URLs are missing")
177
+ return
178
+ }
179
+ var urls :[String] = []
180
+ for url in arr {
181
+ urls.append(url as! String)
182
+ }
183
+ AppsFlyerLib.shared().oneLinkCustomDomains = urls
184
+
185
+ }
186
+
187
+ @objc func addPushNotificationDeepLinkPath(_ call: CAPPluginCall){
188
+ guard let arr = call.getArray(AppsFlyerConstants.AF_PATH) else {
189
+ call.reject("Path is missing")
190
+ return
191
+ }
192
+ var path :[String] = []
193
+ for p in arr {
194
+ path.append(p as! String)
195
+ }
196
+ AppsFlyerLib.shared().addPushNotificationDeepLinkPath(path)
197
+
198
+ }
199
+
200
+ @available(*, deprecated, message: "Use setSharingFilterForPartners")
201
+ @objc func setSharingFilter(_ call: CAPPluginCall){
202
+ let filters = call.getArray(AppsFlyerConstants.AF_FILTERS , String.self)
203
+
204
+ AppsFlyerLib.shared().sharingFilter = filters
205
+
206
+ }
207
+
208
+ @available(*, deprecated, message: "Use setSharingFilterForPartners")
209
+ @objc func setSharingFilterForAllPartners(_ call: CAPPluginCall){
210
+
211
+ AppsFlyerLib.shared().setSharingFilterForAllPartners()
212
+
29
213
  }
30
- let attInterval = call.getInt(AppsFlyerConstants.AF_ATT)
31
214
 
32
- let debug = call.getBool(AppsFlyerConstants.AF_DEBUG, false)
33
- let sandbox = call.getBool(AppsFlyerConstants.AF_SANDBOX, false)
34
- let receiptSandbox = call.getBool(AppsFlyerConstants.AF_RECEIPT_SANDBOX , false)
215
+ @objc func setSharingFilterForPartners(_ call: CAPPluginCall){
216
+ guard let filters = call.getArray(AppsFlyerConstants.AF_FILTERS , String.self) else{
217
+ return call.reject("cannot extract the filters value")
218
+ }
219
+
220
+ AppsFlyerLib.shared().setSharingFilterForPartners(filters)
221
+
222
+ }
35
223
 
36
- conversion = call.getBool(AppsFlyerConstants.AF_CONVERSION_LISTENER, true)
37
- oaoa = call.getBool(AppsFlyerConstants.AF_OAOA, true)
38
- udl = call.getBool(AppsFlyerConstants.AF_UDL, false)
224
+ @objc func setAdditionalData(_ call: CAPPluginCall){
225
+ guard let data = call.getObject(AppsFlyerConstants.AF_ADDITIONAL_DATA) else {
226
+ call.reject("Data is missing")
227
+ return
228
+ }
229
+ AppsFlyerLib.shared().customData = data
230
+
231
+ }
39
232
 
40
- appsflyer.isDebug = debug
41
- appsflyer.appsFlyerDevKey = devKey
42
- appsflyer.appleAppID = appID
43
- appsflyer.useUninstallSandbox = sandbox
44
- appsflyer.useReceiptValidationSandbox = receiptSandbox
45
233
 
46
- if let minTime = call.getInt(AppsFlyerConstants.AF_MIN_TIME){
47
- appsflyer.minTimeBetweenSessions = UInt(minTime)
234
+ @objc func getAppsFlyerUID(_ call: CAPPluginCall){
235
+ let uid = AppsFlyerLib.shared().getAppsFlyerUID()
236
+ call.resolve(["uid":uid])
237
+
48
238
  }
49
239
 
50
- if let timeout = call.getInt(AppsFlyerConstants.AF_DEEP_LINK_TIME_OUT){
51
- appsflyer.deepLinkTimeout = UInt(timeout)
240
+ @objc func setDisableNetworkData(_ call: CAPPluginCall){
241
+ call.unavailable("Android only method - has no effact on iOS apps")
52
242
  }
53
243
 
54
- if conversion || oaoa {
55
- appsflyer.delegate = self
244
+ @objc func anonymizeUser(_ call: CAPPluginCall){
245
+ guard let anonymize = call.getBool(AppsFlyerConstants.AF_ANONYMIZE_USER) else{
246
+ call.reject("Missing boolean value anonymizeUser")
247
+ return
248
+ }
249
+ AppsFlyerLib.shared().anonymizeUser = anonymize
250
+
56
251
  }
57
252
 
58
- if udl {
59
- appsflyer.deepLinkDelegate = self
253
+ @objc func stop(_ call: CAPPluginCall){
254
+ let stop = call.getBool(AppsFlyerConstants.AF_STOP)
255
+ if stop != nil {
256
+ AppsFlyerLib.shared().isStopped = stop!
257
+ }
258
+ call.resolve([AppsFlyerConstants.AF_IS_STOP : AppsFlyerLib.shared().isStopped ])
60
259
  }
61
260
 
62
- reportBridgeReady()
261
+ @objc func disableSKAdNetwork(_ call: CAPPluginCall){
262
+ guard let disable = call.getBool(AppsFlyerConstants.AF_DISABLE_SKAD) else {
263
+ call.reject("Missing boolean value shouldDisable")
264
+ return
265
+ }
266
+ AppsFlyerLib.shared().disableSKAdNetwork = disable
267
+
268
+ }
63
269
 
64
270
  #if !AFSDK_NO_IDFA
65
- if attInterval != nil {
66
- appsflyer.waitForATTUserAuthorization(timeoutInterval: Double(attInterval!))
271
+ @objc func disableAdvertisingIdentifier(_ call: CAPPluginCall){
272
+ guard let disable = call.getBool(AppsFlyerConstants.AF_DISABLE_SKAD) else {
273
+ call.reject("Missing boolean value shouldDisable")
274
+ return
275
+ }
276
+ AppsFlyerLib.shared().disableAdvertisingIdentifier = disable
277
+
67
278
  }
68
279
  #endif
69
280
 
70
- NotificationCenter.default.addObserver(self, selector: #selector(sendLaunch), name: UIApplication.didBecomeActiveNotification, object: nil)
71
-
72
- appsflyer.start(completionHandler: { (dictionnary, error) in
73
- if (error != nil){
74
- call.reject(error!.localizedDescription)
75
- return
76
- } else {
77
- call.resolve(["res":"ok"])
78
- return
79
- }
80
- })
81
- }
82
-
83
- @objc func logEvent(_ call: CAPPluginCall){
84
- guard let eventName = call.getString(AppsFlyerConstants.AF_EVENT_NAME) else{
85
- call.reject("missing event name")
86
- return
87
- }
88
- let eventValue = call.getObject(AppsFlyerConstants.AF_EVENT_VALUE)
89
-
90
- AppsFlyerLib.shared().logEvent(name: eventName, values: eventValue) { (response: [String : Any]?, error: Error?) in
91
- if let response = response {
92
- call.resolve(["res":response])
93
- }
94
- if let error = error {
95
- call.reject(error.localizedDescription, nil, error)
96
- }
97
- }
98
- }
99
-
100
- @objc func setCustomerUserId(_ call: CAPPluginCall){
101
- guard let cuid = call.getString(AppsFlyerConstants.AF_CUID) else {
102
- call.reject("Invalid Customer User ID")
103
- return
104
- }
105
- AppsFlyerLib.shared().customerUserID = cuid
106
-
107
- }
108
-
109
- @objc func setCurrencyCode(_ call: CAPPluginCall){
110
- guard let code = call.getString(AppsFlyerConstants.AF_CURRENCY_CODE) else {
111
- call.reject("Invalid Currency Code")
112
- return
113
- }
114
- AppsFlyerLib.shared().currencyCode = code
115
-
116
-
117
- }
118
-
119
- @objc func updateServerUninstallToken(_ call: CAPPluginCall){
120
- guard let token = call.getString(AppsFlyerConstants.AF_TOKEN) else {
121
- call.reject("Invalid device token")
122
-
123
- return
124
- }
125
-
126
- guard let deviceTokenData = token.hexadecimalToData else{
127
- call.reject("Invalid device token")
128
- return
129
- }
130
- AppsFlyerLib.shared().registerUninstall(deviceTokenData)
131
- }
132
-
133
- @objc func setAppInviteOneLink(_ call: CAPPluginCall){
134
- guard let id = call.getString(AppsFlyerConstants.AF_ONELINK_ID) else {
135
- call.reject("Onelink id is missing")
136
- return
137
- }
138
- AppsFlyerLib.shared().appInviteOneLinkID = id
139
-
140
- }
141
-
142
- @objc func setOneLinkCustomDomain(_ call: CAPPluginCall){
143
- guard let arr = call.getArray(AppsFlyerConstants.AF_ONELINK_DOMAIN) else {
144
- call.reject("Domains are missing")
145
- return
146
- }
147
- var domains :[String] = []
148
- for dom in arr {
149
- domains.append(dom as! String)
150
- }
151
- AppsFlyerLib.shared().oneLinkCustomDomains = domains
152
-
153
- }
154
-
155
- @objc func appendParametersToDeepLinkingURL(_ call: CAPPluginCall){
156
- guard let contains = call.getString(AppsFlyerConstants.AF_CONTAINS) else {
157
- return
158
- }
159
- guard let parameters = call.getObject(AppsFlyerConstants.AF_PARAMETERS) else {
160
- return
161
- }
162
- var params: [String:String] = [:]
163
- for (k,v) in parameters{
164
- params[k] = (v as! String)
165
- }
166
- AppsFlyerLib.shared().appendParametersToDeeplinkURL(contains: contains, parameters:params )
167
-
168
- }
169
-
170
-
171
- @objc func setResolveDeepLinkURLs(_ call: CAPPluginCall){
172
- guard let arr = call.getArray(AppsFlyerConstants.AF_DEEPLINK_URLS) else {
173
- call.reject("URLs are missing")
174
- return
175
- }
176
- var urls :[String] = []
177
- for url in arr {
178
- urls.append(url as! String)
179
- }
180
- AppsFlyerLib.shared().oneLinkCustomDomains = urls
181
-
182
- }
183
-
184
- @objc func addPushNotificationDeepLinkPath(_ call: CAPPluginCall){
185
- guard let arr = call.getArray(AppsFlyerConstants.AF_PATH) else {
186
- call.reject("Path is missing")
187
- return
188
- }
189
- var path :[String] = []
190
- for p in arr {
191
- path.append(p as! String)
192
- }
193
- AppsFlyerLib.shared().addPushNotificationDeepLinkPath(path)
194
-
195
- }
196
-
197
- @available(*, deprecated, message: "Use setSharingFilterForPartners")
198
- @objc func setSharingFilter(_ call: CAPPluginCall){
199
- let filters = call.getArray(AppsFlyerConstants.AF_FILTERS , String.self)
200
-
201
- AppsFlyerLib.shared().sharingFilter = filters
202
-
203
- }
204
-
205
- @available(*, deprecated, message: "Use setSharingFilterForPartners")
206
- @objc func setSharingFilterForAllPartners(_ call: CAPPluginCall){
207
-
208
- AppsFlyerLib.shared().setSharingFilterForAllPartners()
209
-
210
- }
211
-
212
- @objc func setSharingFilterForPartners(_ call: CAPPluginCall){
213
- guard let filters = call.getArray(AppsFlyerConstants.AF_FILTERS , String.self) else{
214
- return call.reject("cannot extract the filters value")
215
- }
216
-
217
- AppsFlyerLib.shared().setSharingFilterForPartners(filters)
218
-
219
- }
220
-
221
- @objc func setAdditionalData(_ call: CAPPluginCall){
222
- guard let data = call.getObject(AppsFlyerConstants.AF_ADDITIONAL_DATA) else {
223
- call.reject("Data is missing")
224
- return
225
- }
226
- AppsFlyerLib.shared().customData = data
227
-
228
- }
229
-
230
-
231
- @objc func getAppsFlyerUID(_ call: CAPPluginCall){
232
- let uid = AppsFlyerLib.shared().getAppsFlyerUID()
233
- call.resolve(["uid":uid])
234
-
235
- }
236
-
237
- @objc func setDisableNetworkData(_ call: CAPPluginCall){
238
- call.unavailable("Android only method - has no effact on iOS apps")
239
- }
240
-
241
- @objc func anonymizeUser(_ call: CAPPluginCall){
242
- guard let anonymize = call.getBool(AppsFlyerConstants.AF_ANONYMIZE_USER) else{
243
- call.reject("Missing boolean value anonymizeUser")
244
- return
245
- }
246
- AppsFlyerLib.shared().anonymizeUser = anonymize
247
-
248
- }
249
-
250
- @objc func stop(_ call: CAPPluginCall){
251
- let stop = call.getBool(AppsFlyerConstants.AF_STOP)
252
- if stop != nil {
253
- AppsFlyerLib.shared().isStopped = stop!
254
- }
255
- call.resolve([AppsFlyerConstants.AF_IS_STOP : AppsFlyerLib.shared().isStopped ])
256
- }
257
-
258
- @objc func disableSKAdNetwork(_ call: CAPPluginCall){
259
- guard let disable = call.getBool(AppsFlyerConstants.AF_DISABLE_SKAD) else {
260
- call.reject("Missing boolean value shouldDisable")
261
- return
262
- }
263
- AppsFlyerLib.shared().disableSKAdNetwork = disable
264
-
265
- }
266
-
267
- #if !AFSDK_NO_IDFA
268
- @objc func disableAdvertisingIdentifier(_ call: CAPPluginCall){
269
- guard let disable = call.getBool(AppsFlyerConstants.AF_DISABLE_SKAD) else {
270
- call.reject("Missing boolean value shouldDisable")
271
- return
281
+ @objc func disableCollectASA(_ call: CAPPluginCall){
282
+ guard let disable = call.getBool(AppsFlyerConstants.AF_DISABLE_SKAD) else {
283
+ call.reject("Missing boolean value shouldDisable")
284
+ return
285
+ }
286
+ AppsFlyerLib.shared().disableCollectASA = disable
287
+
288
+ }
289
+ @objc func setHost(_ call: CAPPluginCall){
290
+ let pre = call.getString(AppsFlyerConstants.AF_HOST_PREFIX)
291
+ let post = call.getString(AppsFlyerConstants.AF_HOST_POSTFIX)
292
+ if (pre != nil && post != nil) {
293
+ AppsFlyerLib.shared().setHost(post!, withHostPrefix: pre!)
294
+ } else {
295
+ call.reject("Missing host prefix and/or host name")
296
+ }
272
297
  }
273
- AppsFlyerLib.shared().disableAdvertisingIdentifier = disable
274
298
 
275
- }
276
- #endif
277
-
278
- @objc func disableCollectASA(_ call: CAPPluginCall){
279
- guard let disable = call.getBool(AppsFlyerConstants.AF_DISABLE_SKAD) else {
280
- call.reject("Missing boolean value shouldDisable")
281
- return
282
- }
283
- AppsFlyerLib.shared().disableCollectASA = disable
284
-
285
- }
286
- @objc func setHost(_ call: CAPPluginCall){
287
- let pre = call.getString(AppsFlyerConstants.AF_HOST_PREFIX)
288
- let post = call.getString(AppsFlyerConstants.AF_HOST_POSTFIX)
289
- if (pre != nil && post != nil) {
290
- AppsFlyerLib.shared().setHost(post!, withHostPrefix: pre!)
291
- } else {
292
- call.reject("Missing host prefix and/or host name")
293
- }
294
- }
295
-
296
- @objc func generateInviteLink(_ call: CAPPluginCall){
297
- AppsFlyerShareInviteHelper.generateInviteUrl(linkGenerator:
298
- {(_ generator: AppsFlyerLinkGenerator) -> AppsFlyerLinkGenerator in
299
- if let channel = call.getString(AppsFlyerConstants.AF_CHANNEL){
300
- generator.setChannel(channel)
301
- }
302
- if let brandDomain = call.getString(AppsFlyerConstants.AF_BRAND_DOMAIN){
303
- generator.brandDomain = brandDomain
304
- }
305
- if let campaign = call.getString(AppsFlyerConstants.AF_CAMPAIGN){
306
- generator.setCampaign(campaign)
307
- }
308
- if let referrerName = call.getString(AppsFlyerConstants.AF_REFERRER_NAME){
309
- generator.setReferrerName(referrerName)
310
- }
311
- if let referrerImageURL = call.getString(AppsFlyerConstants.AF_REFERRER_IMAGE_URL){
312
- generator.setReferrerImageURL(referrerImageURL)
313
- }
314
- if let referrerCustomerId = call.getString(AppsFlyerConstants.AF_REFERRER_CUSTOMER_ID){
315
- generator.setReferrerCustomerId(referrerCustomerId)
316
- }
317
- if let baseDeeplink = call.getString(AppsFlyerConstants.AF_BASE_DEEPLINK){
318
- generator.setBaseDeeplink(baseDeeplink)
319
- }
320
- if let addParameters = call.getObject(AppsFlyerConstants.AF_ADD_PARAMETERS){
321
- generator.addParameters(addParameters)
322
- }
323
-
324
- return generator },completionHandler: {url in
325
- if url != nil{
326
- call.resolve([AppsFlyerConstants.AF_LINK_READY: url!.absoluteString])
299
+ @objc func generateInviteLink(_ call: CAPPluginCall){
300
+ AppsFlyerShareInviteHelper.generateInviteUrl(linkGenerator:
301
+ {(_ generator: AppsFlyerLinkGenerator) -> AppsFlyerLinkGenerator in
302
+ if let channel = call.getString(AppsFlyerConstants.AF_CHANNEL){
303
+ generator.setChannel(channel)
304
+ }
305
+ if let brandDomain = call.getString(AppsFlyerConstants.AF_BRAND_DOMAIN){
306
+ generator.brandDomain = brandDomain
307
+ }
308
+ if let campaign = call.getString(AppsFlyerConstants.AF_CAMPAIGN){
309
+ generator.setCampaign(campaign)
310
+ }
311
+ if let referrerName = call.getString(AppsFlyerConstants.AF_REFERRER_NAME){
312
+ generator.setReferrerName(referrerName)
313
+ }
314
+ if let referrerImageURL = call.getString(AppsFlyerConstants.AF_REFERRER_IMAGE_URL){
315
+ generator.setReferrerImageURL(referrerImageURL)
316
+ }
317
+ if let referrerCustomerId = call.getString(AppsFlyerConstants.AF_REFERRER_CUSTOMER_ID){
318
+ generator.setReferrerCustomerId(referrerCustomerId)
319
+ }
320
+ if let baseDeeplink = call.getString(AppsFlyerConstants.AF_BASE_DEEPLINK){
321
+ generator.setBaseDeeplink(baseDeeplink)
322
+ }
323
+ if let addParameters = call.getObject(AppsFlyerConstants.AF_ADD_PARAMETERS){
324
+ generator.addParameters(addParameters)
325
+ }
326
+
327
+ return generator },completionHandler: {url in
328
+ if url != nil{
329
+ call.resolve([AppsFlyerConstants.AF_LINK_READY: url!.absoluteString])
330
+ }else{
331
+ call.reject("Failed to generate a link")
332
+ }
333
+ }
334
+ )
335
+
336
+ }
337
+ @objc func validateAndLogInAppPurchaseAndroid(_ call: CAPPluginCall){
338
+ call.unavailable()
339
+ }
340
+
341
+ @objc func validateAndLogInAppPurchaseIos(_ call: CAPPluginCall){
342
+ let currency = call.getString(AppsFlyerConstants.AF_CURRENCY)
343
+ let price = call.getString(AppsFlyerConstants.AF_PRICE)
344
+ let _inAppPurchase = call.getString(AppsFlyerConstants.AF_IN_APP_PURCHASE)
345
+ let transactionId = call.getString(AppsFlyerConstants.AF_TRANSACTION_ID)
346
+ let additionalParameters = call.getObject(AppsFlyerConstants.AF_ADDITIONAL_PARAMETERS) ?? [:]
347
+
348
+ if currency != nil && price != nil && _inAppPurchase != nil && transactionId != nil && currency != nil {
349
+ AppsFlyerLib.shared().validateAndLog(
350
+ inAppPurchase: _inAppPurchase,
351
+ price: price,
352
+ currency: currency,
353
+ transactionId: transactionId,
354
+ additionalParameters: additionalParameters,
355
+ success: {result in
356
+ call.resolve(["res":result])
357
+ },
358
+ failure: { error, result in
359
+ guard let emptyInApp = result as? [String:Any]
360
+ else
361
+ {
362
+ call.reject((error)?.localizedDescription ?? "error" )
363
+ return
364
+ }
365
+ call.reject((error)?.localizedDescription ?? "error" , emptyInApp.jsonStringRepresentation)
366
+
367
+ })
327
368
  }else{
328
- call.reject("Failed to generate a link")
329
- }
330
- }
331
- )
332
-
333
- }
334
- @objc func validateAndLogInAppPurchaseAndroid(_ call: CAPPluginCall){
335
- call.unavailable()
336
- }
337
-
338
- @objc func validateAndLogInAppPurchaseIos(_ call: CAPPluginCall){
339
- let currency = call.getString(AppsFlyerConstants.AF_CURRENCY)
340
- let price = call.getString(AppsFlyerConstants.AF_PRICE)
341
- let _inAppPurchase = call.getString(AppsFlyerConstants.AF_IN_APP_PURCHASE)
342
- let transactionId = call.getString(AppsFlyerConstants.AF_TRANSACTION_ID)
343
- let additionalParameters = call.getObject(AppsFlyerConstants.AF_ADDITIONAL_PARAMETERS) ?? [:]
344
-
345
- if currency != nil && price != nil && _inAppPurchase != nil && transactionId != nil && currency != nil {
346
- AppsFlyerLib.shared().validateAndLog(
347
- inAppPurchase: _inAppPurchase,
348
- price: price,
349
- currency: currency,
350
- transactionId: transactionId,
351
- additionalParameters: additionalParameters,
352
- success: {result in
353
- call.resolve(["res":result])
354
- },
355
- failure: { error, result in
356
- guard let emptyInApp = result as? [String:Any]
357
- else
358
- {
359
- call.reject((error)?.localizedDescription ?? "error" )
360
- return
361
- }
362
- call.reject((error)?.localizedDescription ?? "error" , emptyInApp.jsonStringRepresentation)
363
-
364
- })
365
- }else{
366
- call.reject("Missing some fields")
369
+ call.reject("Missing some fields")
370
+ }
371
+
372
+
367
373
  }
368
374
 
369
-
370
- }
371
-
372
- @objc func getSdkVersion(_ call: CAPPluginCall){
373
-
374
- call.resolve(["res": AppsFlyerLib.shared().getSDKVersion()])
375
- }
376
-
377
- @objc func enableFacebookDeferredApplinks(_ call: CAPPluginCall){
378
- guard let enable = call.getBool(AppsFlyerConstants.AF_FB) else {
379
- call.reject("missing boolean value: \(AppsFlyerConstants.AF_FB)")
380
- return
375
+ @objc func getSdkVersion(_ call: CAPPluginCall){
376
+
377
+ call.resolve(["res": AppsFlyerLib.shared().getSDKVersion()])
381
378
  }
382
- if enable{
379
+
380
+ @objc func enableFacebookDeferredApplinks(_ call: CAPPluginCall){
381
+ guard let enable = call.getBool(AppsFlyerConstants.AF_FB) else {
382
+ call.reject("missing boolean value: \(AppsFlyerConstants.AF_FB)")
383
+ return
384
+ }
385
+ if enable{
383
386
  #if canImport(FacebookCore)
384
- AppsFlyerLib.shared().enableFacebookDeferredApplinks(with: FBSDKAppLinkUtility.self)
385
- call.resolve(["res": "enabled"])
387
+ AppsFlyerLib.shared().enableFacebookDeferredApplinks(with: FBSDKAppLinkUtility.self)
388
+ call.resolve(["res": "enabled"])
386
389
  #else
387
- call.reject("Please install FBSDK First!")
390
+ call.reject("Please install FBSDK First!")
388
391
  #endif
389
- }else{
390
- AppsFlyerLib.shared().enableFacebookDeferredApplinks(with: nil)
391
- call.resolve(["res": "disabled"])
392
-
393
- }
394
-
395
- }
396
-
397
- @objc func sendPushNotificationData(_ call: CAPPluginCall){
398
- let json = call.getObject(AppsFlyerConstants.AF_PUSH_PAYLOAD)
399
- AppsFlyerLib.shared().handlePushNotification(json)
400
-
401
- }
402
-
403
-
404
- @objc func setCurrentDeviceLanguage(_ call: CAPPluginCall){
405
- guard let language = call.getString(AppsFlyerConstants.AF_LANGUAGE) else {
406
- call.reject("cannot extract the language value")
407
- return
408
- }
409
- AppsFlyerLib.shared().currentDeviceLanguage = language
410
- call.resolve(["res": "ok"])
411
-
412
- }
413
-
414
- @objc func logCrossPromoteImpression(_ call: CAPPluginCall){
415
- guard let appID = call.getString(AppsFlyerConstants.AF_APP_ID) else {
416
- call.reject("cannot extract the appID value")
417
- return
418
- }
419
- guard let campaign = call.getString(AppsFlyerConstants.AF_CAMPAIGN) else {
420
- call.reject("cannot extract the campaign value")
421
- return
422
- }
423
- guard let parameters = call.getObject(AppsFlyerConstants.AF_PARAMETERS) else {
424
- call.reject("cannot extract the parameters value")
425
- return
426
- }
427
- AppsFlyerCrossPromotionHelper.logCrossPromoteImpression(appID, campaign: campaign, parameters: parameters)
428
- call.resolve(["res": "ok"])
429
-
430
- }
431
-
432
- @objc func setUserEmails(_ call: CAPPluginCall){
433
- guard let emails = call.getArray(AppsFlyerConstants.AF_EMAILS, String.self) else {
434
- call.reject("cannot extract the emails value")
435
- return
436
- }
437
- if let enc = call.getBool(AppsFlyerConstants.AF_ENCODE) , enc == true{
438
- AppsFlyerLib.shared().setUserEmails(emails, with: EmailCryptTypeSHA256)
439
-
440
- }else{
441
- AppsFlyerLib.shared().setUserEmails(emails, with: EmailCryptTypeNone)
442
-
443
- }
444
- call.resolve(["res": "ok"])
445
-
446
- }
447
-
448
- @objc func logLocation(_ call: CAPPluginCall){
449
- guard let longitude = call.getDouble(AppsFlyerConstants.AF_LONGITUDE) else {
450
- call.reject("cannot extract the longitude value")
451
- return
452
- }
453
- guard let latitude = call.getDouble(AppsFlyerConstants.AF_LATITUDE) else {
454
- call.reject("cannot extract the longitude value")
455
- return
456
- }
457
-
458
- AppsFlyerLib.shared().logLocation(longitude: longitude, latitude: latitude)
459
- call.resolve(["res": "ok"])
460
-
461
- }
462
-
463
- @objc func setPhoneNumber(_ call: CAPPluginCall){
464
- guard let phone = call.getString(AppsFlyerConstants.AF_PHONE) else {
465
- call.reject("cannot extract the phone value")
466
- return
467
- }
468
-
469
- AppsFlyerLib.shared().phoneNumber = phone
470
- call.resolve(["res": "ok"])
471
-
472
- }
473
-
474
- @objc func setPartnerData(_ call: CAPPluginCall){
475
- guard let data = call.getObject(AppsFlyerConstants.AF_DATA) else {
476
- call.reject("cannot extract the data value")
477
- return
478
- }
479
- guard let pid = call.getString(AppsFlyerConstants.AF_PARTNER_ID) else {
480
- call.reject("cannot extract the partnerId value")
481
- return
482
- }
483
-
484
- AppsFlyerLib.shared().setPartnerData(partnerId: pid, partnerInfo: data)
485
- call.resolve(["res": "ok"])
486
-
487
- }
488
-
489
- @objc func logInvite(_ call: CAPPluginCall){
490
- guard let data = call.getObject(AppsFlyerConstants.AF_EVENT_PARAMETERS) else {
491
- call.reject("cannot extract the eventParameters value")
492
- return
392
+ }else{
393
+ AppsFlyerLib.shared().enableFacebookDeferredApplinks(with: nil)
394
+ call.resolve(["res": "disabled"])
395
+
396
+ }
397
+
398
+ }
399
+
400
+ @objc func sendPushNotificationData(_ call: CAPPluginCall){
401
+ let json = call.getObject(AppsFlyerConstants.AF_PUSH_PAYLOAD)
402
+ AppsFlyerLib.shared().handlePushNotification(json)
403
+
404
+ }
405
+
406
+
407
+ @objc func setCurrentDeviceLanguage(_ call: CAPPluginCall){
408
+ guard let language = call.getString(AppsFlyerConstants.AF_LANGUAGE) else {
409
+ call.reject("cannot extract the language value")
410
+ return
411
+ }
412
+ AppsFlyerLib.shared().currentDeviceLanguage = language
413
+ call.resolve(["res": "ok"])
414
+
415
+ }
416
+
417
+ @objc func logCrossPromoteImpression(_ call: CAPPluginCall){
418
+ guard let appID = call.getString(AppsFlyerConstants.AF_APP_ID) else {
419
+ call.reject("cannot extract the appID value")
420
+ return
421
+ }
422
+ guard let campaign = call.getString(AppsFlyerConstants.AF_CAMPAIGN) else {
423
+ call.reject("cannot extract the campaign value")
424
+ return
425
+ }
426
+ guard let parameters = call.getObject(AppsFlyerConstants.AF_PARAMETERS) else {
427
+ call.reject("cannot extract the parameters value")
428
+ return
429
+ }
430
+ AppsFlyerCrossPromotionHelper.logCrossPromoteImpression(appID, campaign: campaign, parameters: parameters)
431
+ call.resolve(["res": "ok"])
432
+
433
+ }
434
+
435
+ @objc func setUserEmails(_ call: CAPPluginCall){
436
+ guard let emails = call.getArray(AppsFlyerConstants.AF_EMAILS, String.self) else {
437
+ call.reject("cannot extract the emails value")
438
+ return
439
+ }
440
+ if let enc = call.getBool(AppsFlyerConstants.AF_ENCODE) , enc == true{
441
+ AppsFlyerLib.shared().setUserEmails(emails, with: EmailCryptTypeSHA256)
442
+
443
+ }else{
444
+ AppsFlyerLib.shared().setUserEmails(emails, with: EmailCryptTypeNone)
445
+
446
+ }
447
+ call.resolve(["res": "ok"])
448
+
449
+ }
450
+
451
+ @objc func logLocation(_ call: CAPPluginCall){
452
+ guard let longitude = call.getDouble(AppsFlyerConstants.AF_LONGITUDE) else {
453
+ call.reject("cannot extract the longitude value")
454
+ return
455
+ }
456
+ guard let latitude = call.getDouble(AppsFlyerConstants.AF_LATITUDE) else {
457
+ call.reject("cannot extract the longitude value")
458
+ return
459
+ }
460
+
461
+ AppsFlyerLib.shared().logLocation(longitude: longitude, latitude: latitude)
462
+ call.resolve(["res": "ok"])
463
+
464
+ }
465
+
466
+ @objc func setPhoneNumber(_ call: CAPPluginCall){
467
+ guard let phone = call.getString(AppsFlyerConstants.AF_PHONE) else {
468
+ call.reject("cannot extract the phone value")
469
+ return
470
+ }
471
+
472
+ AppsFlyerLib.shared().phoneNumber = phone
473
+ call.resolve(["res": "ok"])
474
+
475
+ }
476
+
477
+ @objc func setPartnerData(_ call: CAPPluginCall){
478
+ guard let data = call.getObject(AppsFlyerConstants.AF_DATA) else {
479
+ call.reject("cannot extract the data value")
480
+ return
481
+ }
482
+ guard let pid = call.getString(AppsFlyerConstants.AF_PARTNER_ID) else {
483
+ call.reject("cannot extract the partnerId value")
484
+ return
485
+ }
486
+
487
+ AppsFlyerLib.shared().setPartnerData(partnerId: pid, partnerInfo: data)
488
+ call.resolve(["res": "ok"])
489
+
490
+ }
491
+
492
+ @objc func logInvite(_ call: CAPPluginCall){
493
+ guard let data = call.getObject(AppsFlyerConstants.AF_EVENT_PARAMETERS) else {
494
+ call.reject("cannot extract the eventParameters value")
495
+ return
496
+ }
497
+ guard let channel = call.getString(AppsFlyerConstants.AF_CHANNEL) else {
498
+ call.reject("cannot extract the channel value")
499
+ return
500
+ }
501
+
502
+ AppsFlyerShareInviteHelper.logInvite(channel, parameters: data)
503
+ call.resolve(["res": "ok"])
504
+
493
505
  }
494
- guard let channel = call.getString(AppsFlyerConstants.AF_CHANNEL) else {
495
- call.reject("cannot extract the channel value")
496
- return
497
- }
498
-
499
- AppsFlyerShareInviteHelper.logInvite(channel, parameters: data)
500
- call.resolve(["res": "ok"])
501
-
502
- }
503
506
  }
504
507
 
505
508
  extension AppsFlyerPlugin{
506
- private func reportBridgeReady(){
507
- AppsFlyerAttribution.shared.bridgReady = true
508
- NotificationCenter.default.post(name: Notification.Name.appsflyerBridge, object: nil)
509
- }
510
-
511
- @objc private func sendLaunch(){
512
- AppsFlyerLib.shared().start()
513
- }
514
-
515
- @objc func handleUrlOpened(notification: NSNotification) {
516
- guard let object = notification.object as? [String: Any?] else {
517
- return
518
- }
519
- guard let url = object["url"] else {
520
- afLogger(msg: "handleUrlOpened url is nil")
521
- return
522
- }
523
- guard let options = object["options"] else {
524
- afLogger(msg: "handleUrlOpened options is nil")
525
-
526
- return
527
- }
528
- afLogger(msg: "handleUrlOpened with \((url as! URL).absoluteString)")
529
- AppsFlyerAttribution.shared.handleOpenUrl(open: url as! URL, options: options as! [UIApplication.OpenURLOptionsKey: Any])
530
-
531
- }
532
-
533
- @objc func handleUniversalLink(notification: NSNotification) {
534
- guard let object = notification.object as? [String: Any?] else {
535
- return
536
- }
537
- let user = NSUserActivity(activityType: NSUserActivityTypeBrowsingWeb)
538
- guard let url = object["url"] else {
539
- afLogger(msg: "handleUrlOpened options is url")
540
- return
541
- }
542
- user.webpageURL = (url as! URL)
543
- afLogger(msg: "handleUniversalLink with \(user.webpageURL?.absoluteString ?? "null")")
544
- AppsFlyerAttribution.shared.continueUserActivity(userActivity: user)
545
-
546
- }
547
-
509
+ private func reportBridgeReady(){
510
+ AppsFlyerAttribution.shared.bridgReady = true
511
+ NotificationCenter.default.post(name: Notification.Name.appsflyerBridge, object: nil)
512
+ }
513
+
514
+ @objc private func sendLaunch(){
515
+ AppsFlyerLib.shared().start()
516
+ }
517
+
518
+ @objc func handleUrlOpened(notification: NSNotification) {
519
+ guard let object = notification.object as? [String: Any?] else {
520
+ return
521
+ }
522
+ guard let url = object["url"] else {
523
+ afLogger(msg: "handleUrlOpened url is nil")
524
+ return
525
+ }
526
+ guard let options = object["options"] else {
527
+ afLogger(msg: "handleUrlOpened options is nil")
528
+
529
+ return
530
+ }
531
+ afLogger(msg: "handleUrlOpened with \((url as! URL).absoluteString)")
532
+ AppsFlyerAttribution.shared.handleOpenUrl(open: url as! URL, options: options as! [UIApplication.OpenURLOptionsKey: Any])
533
+
534
+ }
535
+
536
+ @objc func handleUniversalLink(notification: NSNotification) {
537
+ guard let object = notification.object as? [String: Any?] else {
538
+ return
539
+ }
540
+ let user = NSUserActivity(activityType: NSUserActivityTypeBrowsingWeb)
541
+ guard let url = object["url"] else {
542
+ afLogger(msg: "handleUrlOpened options is url")
543
+ return
544
+ }
545
+ user.webpageURL = (url as! URL)
546
+ afLogger(msg: "handleUniversalLink with \(user.webpageURL?.absoluteString ?? "null")")
547
+ AppsFlyerAttribution.shared.continueUserActivity(userActivity: user)
548
+
549
+ }
550
+
548
551
  }
549
552
 
550
553
  extension AppsFlyerPlugin : AppsFlyerLibDelegate {
551
- public func onConversionDataSuccess(_ conversionInfo: [AnyHashable : Any]) {
552
- let json : [String: Any] = ["callbackName":"onConversionDataSuccess", "data":conversionInfo]
553
- self.notifyListeners(AppsFlyerConstants.CONVERSION_CALLBACK, data: json)
554
-
555
- }
556
-
557
- public func onConversionDataFail(_ error: Error) {
558
- let json : [String: Any] = ["callbackName":"onConversionDataFail", "status":error.localizedDescription]
559
- self.notifyListeners(AppsFlyerConstants.CONVERSION_CALLBACK, data: json)
560
- }
561
- public func onAppOpenAttribution(_ attributionData: [AnyHashable : Any]) {
562
- let json : [String: Any] = ["callbackName":"onAppOpenAttribution", "data":attributionData]
563
- self.notifyListeners(AppsFlyerConstants.OAOA_CALLBACK, data: json)
564
- }
565
-
566
- public func onAppOpenAttributionFailure(_ error: Error) {
567
- let json : [String: Any] = ["callbackName":"onAppOpenAttributionFailure", "status":error.localizedDescription]
568
- self.notifyListeners(AppsFlyerConstants.OAOA_CALLBACK, data: json)
569
-
570
- }
571
-
554
+ public func onConversionDataSuccess(_ conversionInfo: [AnyHashable : Any]) {
555
+ let json : [String: Any] = ["callbackName":"onConversionDataSuccess", "data":conversionInfo]
556
+ self.notifyListeners(AppsFlyerConstants.CONVERSION_CALLBACK, data: json)
557
+
558
+ }
559
+
560
+ public func onConversionDataFail(_ error: Error) {
561
+ let json : [String: Any] = ["callbackName":"onConversionDataFail", "status":error.localizedDescription]
562
+ self.notifyListeners(AppsFlyerConstants.CONVERSION_CALLBACK, data: json)
563
+ }
564
+ public func onAppOpenAttribution(_ attributionData: [AnyHashable : Any]) {
565
+ let json : [String: Any] = ["callbackName":"onAppOpenAttribution", "data":attributionData]
566
+ self.notifyListeners(AppsFlyerConstants.OAOA_CALLBACK, data: json)
567
+ }
568
+
569
+ public func onAppOpenAttributionFailure(_ error: Error) {
570
+ let json : [String: Any] = ["callbackName":"onAppOpenAttributionFailure", "status":error.localizedDescription]
571
+ self.notifyListeners(AppsFlyerConstants.OAOA_CALLBACK, data: json)
572
+
573
+ }
574
+
572
575
  }
573
576
 
574
577
 
575
578
  // Mark -
576
579
  extension AppsFlyerPlugin : DeepLinkDelegate{
577
- public func didResolveDeepLink(_ result: DeepLinkResult) {
578
- var json : [String: Any] = [:]
579
-
580
- switch result.status {
581
- case .notFound :
582
- json["status"] = "NOT_FOUND"
583
- case .failure :
584
- json["status"] = "FAILURE"
585
- case .found :
586
- json["status"] = "FOUND"
580
+ public func didResolveDeepLink(_ result: DeepLinkResult) {
581
+ var json : [String: Any] = [:]
582
+
583
+ switch result.status {
584
+ case .notFound :
585
+ json["status"] = "NOT_FOUND"
586
+ case .failure :
587
+ json["status"] = "FAILURE"
588
+ case .found :
589
+ json["status"] = "FOUND"
590
+ }
591
+
592
+ if result.error != nil {
593
+ json["error"] = result.error!.localizedDescription
594
+ }
595
+ if result.deepLink != nil {
596
+ var deepLinkDic = result.deepLink!.clickEvent
597
+ deepLinkDic["is_deferred"] = result.deepLink!.isDeferred
598
+ json["deepLink"] = deepLinkDic
599
+ }
600
+ self.notifyListeners(AppsFlyerConstants.UDL_CALLBACK, data: json)
587
601
  }
588
602
 
589
- if result.error != nil {
590
- json["error"] = result.error!.localizedDescription
591
- }
592
- if result.deepLink != nil {
593
- var deepLinkDic = result.deepLink!.clickEvent
594
- deepLinkDic["is_deferred"] = result.deepLink!.isDeferred
595
- json["deepLink"] = deepLinkDic
596
- }
597
- self.notifyListeners(AppsFlyerConstants.UDL_CALLBACK, data: json)
598
- }
599
-
600
603
  }
601
604
 
602
605
  extension AppsFlyerPlugin{
603
- private func afLogger(msg : String){
604
- NSLog ("AppsFlyer [Debug][Capacitor]: \(msg)");
605
- }
606
+ private func afLogger(msg : String){
607
+ NSLog ("AppsFlyer [Debug][Capacitor]: \(msg)");
608
+ }
606
609
  }
607
-
608
-
package/package.json CHANGED
@@ -1,7 +1,9 @@
1
1
  {
2
2
  "name": "appsflyer-capacitor-plugin",
3
- "version": "6.9.2",
4
- "iosSdkVersion": "6.9.0",
3
+ "version": "6.10.3-rc1",
4
+ "iosSdkVersion": "6.10.1",
5
+ "androidSdkVersion": "6.10.3",
6
+ "buildNumber": "65",
5
7
  "description": "AppsFlyer SDK plugin for Capacitor",
6
8
  "main": "dist/plugin.cjs.js",
7
9
  "module": "dist/esm/index.js",