@dashx/react-native 0.1.7 → 0.1.11
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 +17 -0
- package/android/README.md +19 -10
- package/android/build.gradle +1 -1
- package/android/src/main/AndroidManifest.xml +1 -1
- package/android/src/main/java/com/dashx/rn/sdk/DashXClientInterceptor.kt +2 -2
- package/android/src/main/java/com/dashx/rn/sdk/DashXModule.kt +5 -1
- package/ios/API.swift +119 -64
- package/ios/DashX.m +1 -0
- package/ios/DashX.swift +5 -4
- package/ios/DashXClient.swift +14 -16
- package/ios/README.md +80 -0
- package/ios/schema.json +15894 -19969
- package/package.json +1 -1
- package/android/.gradle/6.9/executionHistory/executionHistory.bin +0 -0
- package/android/.gradle/6.9/executionHistory/executionHistory.lock +0 -0
- package/android/.gradle/6.9/fileChanges/last-build.bin +0 -0
- package/android/.gradle/6.9/fileHashes/fileHashes.bin +0 -0
- package/android/.gradle/6.9/fileHashes/fileHashes.lock +0 -0
- package/android/.gradle/6.9/fileHashes/resourceHashesCache.bin +0 -0
- package/android/.gradle/6.9/gc.properties +0 -0
- package/android/.gradle/6.9/javaCompile/classAnalysis.bin +0 -0
- package/android/.gradle/6.9/javaCompile/jarAnalysis.bin +0 -0
- package/android/.gradle/6.9/javaCompile/javaCompile.lock +0 -0
- package/android/.gradle/6.9/javaCompile/taskHistory.bin +0 -0
- package/android/.gradle/6.9/vcsMetadata-1/vcsMetadata-1.lock +0 -0
- package/android/.gradle/6.9/vcsMetadata-1/workingDirs.bin +0 -0
- package/android/.gradle/7.0.2/dependencies-accessors/dependencies-accessors.lock +0 -0
- package/android/.gradle/7.0.2/dependencies-accessors/gc.properties +0 -0
- package/android/.gradle/7.0.2/fileChanges/last-build.bin +0 -0
- package/android/.gradle/7.0.2/fileHashes/fileHashes.lock +0 -0
- package/android/.gradle/7.0.2/gc.properties +0 -0
- package/android/.gradle/buildOutputCleanup/buildOutputCleanup.lock +0 -0
- package/android/.gradle/buildOutputCleanup/cache.properties +0 -2
- package/android/.gradle/buildOutputCleanup/outputFiles.bin +0 -0
- package/android/.gradle/checksums/checksums.lock +0 -0
- package/android/.gradle/checksums/md5-checksums.bin +0 -0
- package/android/.gradle/checksums/sha1-checksums.bin +0 -0
- package/android/.gradle/vcs-1/gc.properties +0 -0
- package/android/.gradle/vcs-1/vcs-1.lock +0 -0
- package/android/.idea/.gitignore +0 -3
- package/android/.idea/compiler.xml +0 -6
- package/android/.idea/gradle.xml +0 -19
- package/android/.idea/jarRepositories.xml +0 -55
- package/android/.idea/libraries/Gradle__androidx_annotation_annotation_1_0_0.xml +0 -9
- package/android/.idea/libraries/Gradle__androidx_appcompat_appcompat_1_0_2_aar.xml +0 -14
- package/android/.idea/libraries/Gradle__androidx_arch_core_core_common_2_0_0.xml +0 -9
- package/android/.idea/libraries/Gradle__androidx_arch_core_core_runtime_2_0_0_aar.xml +0 -11
- package/android/.idea/libraries/Gradle__androidx_asynclayoutinflater_asynclayoutinflater_1_0_0_aar.xml +0 -11
- package/android/.idea/libraries/Gradle__androidx_collection_collection_1_0_0.xml +0 -9
- package/android/.idea/libraries/Gradle__androidx_coordinatorlayout_coordinatorlayout_1_0_0_aar.xml +0 -14
- package/android/.idea/libraries/Gradle__androidx_core_core_1_0_1_aar.xml +0 -14
- package/android/.idea/libraries/Gradle__androidx_cursoradapter_cursoradapter_1_0_0_aar.xml +0 -11
- package/android/.idea/libraries/Gradle__androidx_customview_customview_1_0_0_aar.xml +0 -11
- package/android/.idea/libraries/Gradle__androidx_documentfile_documentfile_1_0_0_aar.xml +0 -11
- package/android/.idea/libraries/Gradle__androidx_drawerlayout_drawerlayout_1_0_0_aar.xml +0 -14
- package/android/.idea/libraries/Gradle__androidx_fragment_fragment_1_0_0_aar.xml +0 -14
- package/android/.idea/libraries/Gradle__androidx_interpolator_interpolator_1_0_0_aar.xml +0 -11
- package/android/.idea/libraries/Gradle__androidx_legacy_legacy_support_core_ui_1_0_0_aar.xml +0 -11
- package/android/.idea/libraries/Gradle__androidx_legacy_legacy_support_core_utils_1_0_0_aar.xml +0 -11
- package/android/.idea/libraries/Gradle__androidx_lifecycle_lifecycle_common_2_0_0.xml +0 -9
- package/android/.idea/libraries/Gradle__androidx_lifecycle_lifecycle_livedata_2_0_0_aar.xml +0 -11
- package/android/.idea/libraries/Gradle__androidx_lifecycle_lifecycle_livedata_core_2_0_0_aar.xml +0 -11
- package/android/.idea/libraries/Gradle__androidx_lifecycle_lifecycle_runtime_2_0_0_aar.xml +0 -11
- package/android/.idea/libraries/Gradle__androidx_lifecycle_lifecycle_viewmodel_2_0_0_aar.xml +0 -11
- package/android/.idea/libraries/Gradle__androidx_loader_loader_1_0_0_aar.xml +0 -11
- package/android/.idea/libraries/Gradle__androidx_localbroadcastmanager_localbroadcastmanager_1_0_0_aar.xml +0 -11
- package/android/.idea/libraries/Gradle__androidx_print_print_1_0_0_aar.xml +0 -14
- package/android/.idea/libraries/Gradle__androidx_slidingpanelayout_slidingpanelayout_1_0_0_aar.xml +0 -11
- package/android/.idea/libraries/Gradle__androidx_swiperefreshlayout_swiperefreshlayout_1_0_0_aar.xml +0 -14
- package/android/.idea/libraries/Gradle__androidx_vectordrawable_vectordrawable_1_0_1_aar.xml +0 -11
- package/android/.idea/libraries/Gradle__androidx_vectordrawable_vectordrawable_animated_1_0_0_aar.xml +0 -11
- package/android/.idea/libraries/Gradle__androidx_versionedparcelable_versionedparcelable_1_0_0_aar.xml +0 -11
- package/android/.idea/libraries/Gradle__androidx_viewpager_viewpager_1_0_0_aar.xml +0 -11
- package/android/.idea/libraries/Gradle__com_facebook_fbjni_fbjni_java_only_0_0_3.xml +0 -9
- package/android/.idea/libraries/Gradle__com_facebook_fresco_drawee_2_0_0_aar.xml +0 -11
- package/android/.idea/libraries/Gradle__com_facebook_fresco_fbcore_2_0_0_aar.xml +0 -14
- package/android/.idea/libraries/Gradle__com_facebook_fresco_fresco_2_0_0_aar.xml +0 -14
- package/android/.idea/libraries/Gradle__com_facebook_fresco_imagepipeline_2_0_0_aar.xml +0 -14
- package/android/.idea/libraries/Gradle__com_facebook_fresco_imagepipeline_base_2_0_0_aar.xml +0 -14
- package/android/.idea/libraries/Gradle__com_facebook_fresco_imagepipeline_okhttp3_2_0_0_aar.xml +0 -11
- package/android/.idea/libraries/Gradle__com_facebook_fresco_nativeimagefilters_2_0_0_aar.xml +0 -11
- package/android/.idea/libraries/Gradle__com_facebook_fresco_nativeimagetranscoder_2_0_0_aar.xml +0 -11
- package/android/.idea/libraries/Gradle__com_facebook_infer_annotation_infer_annotation_0_11_2.xml +0 -9
- package/android/.idea/libraries/Gradle__com_facebook_react_react_native_0_62_3_aar.xml +0 -14
- package/android/.idea/libraries/Gradle__com_facebook_soloader_annotation_0_8_0_aar.xml +0 -11
- package/android/.idea/libraries/Gradle__com_facebook_soloader_nativeloader_0_8_0.xml +0 -9
- package/android/.idea/libraries/Gradle__com_facebook_soloader_soloader_0_8_0_aar.xml +0 -11
- package/android/.idea/libraries/Gradle__com_facebook_yoga_proguard_annotations_1_14_1.xml +0 -9
- package/android/.idea/libraries/Gradle__com_github_dashxhq_dashx_android_set_uid_in_identify_SNAPSHOT_aar.xml +0 -11
- package/android/.idea/libraries/Gradle__com_google_android_gms_play_services_ads_identifier_17_0_0_aar.xml +0 -11
- package/android/.idea/libraries/Gradle__com_google_android_gms_play_services_base_17_0_0_aar.xml +0 -11
- package/android/.idea/libraries/Gradle__com_google_android_gms_play_services_basement_17_0_0_aar.xml +0 -11
- package/android/.idea/libraries/Gradle__com_google_android_gms_play_services_measurement_17_2_1_aar.xml +0 -11
- package/android/.idea/libraries/Gradle__com_google_android_gms_play_services_measurement_api_17_2_1_aar.xml +0 -11
- package/android/.idea/libraries/Gradle__com_google_android_gms_play_services_measurement_base_17_2_1_aar.xml +0 -11
- package/android/.idea/libraries/Gradle__com_google_android_gms_play_services_measurement_impl_17_2_1_aar.xml +0 -11
- package/android/.idea/libraries/Gradle__com_google_android_gms_play_services_measurement_sdk_17_2_1_aar.xml +0 -11
- package/android/.idea/libraries/Gradle__com_google_android_gms_play_services_measurement_sdk_api_17_2_1_aar.xml +0 -11
- package/android/.idea/libraries/Gradle__com_google_android_gms_play_services_stats_17_0_0_aar.xml +0 -11
- package/android/.idea/libraries/Gradle__com_google_android_gms_play_services_tasks_17_0_0_aar.xml +0 -11
- package/android/.idea/libraries/Gradle__com_google_auto_value_auto_value_annotations_1_6_5.xml +0 -9
- package/android/.idea/libraries/Gradle__com_google_code_findbugs_jsr305_3_0_2.xml +0 -9
- package/android/.idea/libraries/Gradle__com_google_code_gson_gson_2_8_6.xml +0 -9
- package/android/.idea/libraries/Gradle__com_google_firebase_firebase_analytics_17_2_1_aar.xml +0 -11
- package/android/.idea/libraries/Gradle__com_google_firebase_firebase_common_19_2_0_aar.xml +0 -11
- package/android/.idea/libraries/Gradle__com_google_firebase_firebase_core_17_2_1_aar.xml +0 -11
- package/android/.idea/libraries/Gradle__com_google_firebase_firebase_iid_20_0_1_aar.xml +0 -11
- package/android/.idea/libraries/Gradle__com_google_firebase_firebase_iid_interop_17_0_0_aar.xml +0 -11
- package/android/.idea/libraries/Gradle__com_google_firebase_firebase_measurement_connector_18_0_0_aar.xml +0 -11
- package/android/.idea/libraries/Gradle__com_google_firebase_firebase_messaging_20_0_1_aar.xml +0 -11
- package/android/.idea/libraries/Gradle__com_squareup_okhttp3_okhttp_4_2_2.xml +0 -9
- package/android/.idea/libraries/Gradle__com_squareup_okhttp3_okhttp_urlconnection_3_12_1.xml +0 -9
- package/android/.idea/libraries/Gradle__com_squareup_okio_okio_2_9_0.xml +0 -9
- package/android/.idea/libraries/Gradle__javax_inject_javax_inject_1.xml +0 -9
- package/android/.idea/libraries/Gradle__org_jetbrains_annotations_13_0.xml +0 -9
- package/android/.idea/libraries/Gradle__org_jetbrains_kotlin_kotlin_stdlib_1_5_20.xml +0 -9
- package/android/.idea/libraries/Gradle__org_jetbrains_kotlin_kotlin_stdlib_common_1_5_20.xml +0 -9
- package/android/.idea/libraries/Gradle__org_jetbrains_kotlin_kotlin_stdlib_jdk7_1_5_20.xml +0 -9
- package/android/.idea/libraries/Gradle__org_jetbrains_kotlin_kotlin_stdlib_jdk8_1_5_20.xml +0 -9
- package/android/.idea/misc.xml +0 -9
- package/android/.idea/modules/android.iml +0 -151
- package/android/.idea/modules.xml +0 -8
- package/android/.idea/vcs.xml +0 -6
- package/android/.idea/workspace.xml +0 -130
- package/android/build/generated/checks/apollo/debug/service/duplicatesCheck +0 -1
- package/android/build/generated/checks/apollo/versionCheck +0 -1
- package/android/build/generated/source/buildConfig/debug/com/dashx/rn/sdk/BuildConfig.java +0 -13
- package/android/build/intermediates/aapt_friendly_merged_manifests/debug/aapt/AndroidManifest.xml +0 -19
- package/android/build/intermediates/aapt_friendly_merged_manifests/debug/aapt/output.json +0 -1
- package/android/build/intermediates/compile_only_not_namespaced_r_class_jar/debug/generateDebugRFile/R.jar +0 -0
- package/android/build/intermediates/incremental/packageDebugResources/compile-file-map.properties +0 -1
- package/android/build/intermediates/incremental/packageDebugResources/merger.xml +0 -2
- package/android/build/intermediates/library_manifest/debug/AndroidManifest.xml +0 -19
- package/android/build/intermediates/merged_manifests/debug/output.json +0 -1
- package/android/build/intermediates/res/symbol-table-with-package/debug/package-aware-r.txt +0 -186
- package/android/build/intermediates/symbols/debug/R.txt +0 -233
- package/android/build/kotlin/compileDebugKotlin/build-history.bin +0 -0
- package/android/build/kotlin/compileDebugKotlin/dirty-sources.txt +0 -7
- package/android/build/libs/android-javadoc.jar +0 -0
- package/android/build/libs/android-sources.jar +0 -0
- package/android/build/outputs/logs/manifest-merger-debug-report.txt +0 -51
- package/android/build/tmp/androidJavadocJar/MANIFEST.MF +0 -2
- package/android/build/tmp/androidSourcesJar/MANIFEST.MF +0 -2
- package/android/local.properties +0 -8
- package/ios/DashX.xcworkspace/xcuserdata/rajatsharma.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
package/README.md
CHANGED
|
@@ -176,3 +176,20 @@ You can generate identity token by using `POST` `/v1/generate_token` which accep
|
|
|
176
176
|
"key": "dashx_private_key"
|
|
177
177
|
}
|
|
178
178
|
```
|
|
179
|
+
|
|
180
|
+
## Development
|
|
181
|
+
|
|
182
|
+
### Setting up development environment
|
|
183
|
+
|
|
184
|
+
Please follow [these steps](https://github.com/dashxhq/dashx-js/tree/master/examples/react-native#setting-up-development-environment) to set-up development environment.
|
|
185
|
+
|
|
186
|
+
You'll also need Apollo CLI to generate files.
|
|
187
|
+
|
|
188
|
+
```sh
|
|
189
|
+
$ npm i -g apollo
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
For the next steps, please follow the guide for the respective platform:
|
|
193
|
+
|
|
194
|
+
- [Android](android/README.md)
|
|
195
|
+
- [iOS](ios/README.md)
|
package/android/README.md
CHANGED
|
@@ -1,14 +1,23 @@
|
|
|
1
|
-
|
|
2
|
-
======
|
|
1
|
+
# Android Native Module
|
|
3
2
|
|
|
4
|
-
|
|
3
|
+
## Prerequisites
|
|
5
4
|
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
- NodeJS
|
|
6
|
+
- Android Studio
|
|
7
|
+
- Android SDK
|
|
8
|
+
|
|
9
|
+
## Development
|
|
10
|
+
|
|
11
|
+
- This native module uses DashX Android SDK to make API calls, so if you want to add any graphql requests add to [dashx-android](https://github.com/dashxhq/dashx-android).
|
|
12
|
+
|
|
13
|
+
- Make sure all the Node dependencies are installed:
|
|
14
|
+
|
|
15
|
+
```sh
|
|
16
|
+
$ yarn
|
|
8
17
|
```
|
|
9
|
-
|
|
10
|
-
|
|
18
|
+
|
|
19
|
+
- To build this module:
|
|
20
|
+
|
|
21
|
+
```sh
|
|
22
|
+
$ ./gradlew build
|
|
11
23
|
```
|
|
12
|
-
3. Delete the `maven` folder
|
|
13
|
-
4. Run `./gradlew installArchives`
|
|
14
|
-
5. Verify that latest set of generated files is in the maven folder with the correct version number
|
package/android/build.gradle
CHANGED
|
@@ -90,7 +90,7 @@ repositories {
|
|
|
90
90
|
}
|
|
91
91
|
|
|
92
92
|
dependencies {
|
|
93
|
-
implementation 'com.github.dashxhq:dashx-android:
|
|
93
|
+
implementation 'com.github.dashxhq:dashx-android:main-SNAPSHOT'
|
|
94
94
|
//noinspection GradleDynamicVersion
|
|
95
95
|
implementation 'com.facebook.react:react-native:+' // From node_modules
|
|
96
96
|
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
package="com.dashx.rn.sdk">
|
|
3
3
|
|
|
4
4
|
<application>
|
|
5
|
-
<service android:name="com.dashx.
|
|
5
|
+
<service android:name="com.dashx.rn.sdk.DashXMessagingService">
|
|
6
6
|
<intent-filter android:priority="1">
|
|
7
7
|
<action android:name="com.google.firebase.MESSAGING_EVENT"/>
|
|
8
8
|
</intent-filter>
|
|
@@ -14,9 +14,9 @@ class DashXClientInterceptor private constructor() {
|
|
|
14
14
|
var reactApplicationContext: ReactApplicationContext? = null
|
|
15
15
|
private val dashXNotificationFilter = "DASHX_PN_TYPE"
|
|
16
16
|
|
|
17
|
-
fun createDashXClient(reactApplicationContext: ReactApplicationContext, publicKey: String, baseURI: String?,
|
|
17
|
+
fun createDashXClient(reactApplicationContext: ReactApplicationContext, publicKey: String, baseURI: String?, targetEnvironment: String?, targetInstallation: String?) {
|
|
18
18
|
this.reactApplicationContext = reactApplicationContext
|
|
19
|
-
client = DashX(reactApplicationContext.applicationContext, publicKey!!, baseURI,
|
|
19
|
+
client = DashX(reactApplicationContext.applicationContext, publicKey!!, baseURI, targetEnvironment, targetInstallation)
|
|
20
20
|
}
|
|
21
21
|
|
|
22
22
|
fun getDashXClient(): com.dashx.sdk.DashXClient {
|
|
@@ -25,7 +25,6 @@ class DashXModule(private val reactContext: ReactApplicationContext) : ReactCont
|
|
|
25
25
|
reactContext,
|
|
26
26
|
options.getString("publicKey")!!,
|
|
27
27
|
options.getStringIfPresent("baseUri"),
|
|
28
|
-
options.getStringIfPresent("accountType"),
|
|
29
28
|
options.getStringIfPresent("targetEnvironment"),
|
|
30
29
|
options.getStringIfPresent("targetInstallation")
|
|
31
30
|
)
|
|
@@ -186,4 +185,9 @@ class DashXModule(private val reactContext: ReactApplicationContext) : ReactCont
|
|
|
186
185
|
}
|
|
187
186
|
)
|
|
188
187
|
}
|
|
188
|
+
|
|
189
|
+
@ReactMethod
|
|
190
|
+
fun subscribe() {
|
|
191
|
+
interceptor.getDashXClient().subscribe()
|
|
192
|
+
}
|
|
189
193
|
}
|
package/ios/API.swift
CHANGED
|
@@ -49,7 +49,6 @@ public enum DashXGql {
|
|
|
49
49
|
public var graphQLMap: GraphQLMap
|
|
50
50
|
|
|
51
51
|
/// - Parameters:
|
|
52
|
-
/// - accountType
|
|
53
52
|
/// - accountUid
|
|
54
53
|
/// - accountAnonymousUid
|
|
55
54
|
/// - itemId
|
|
@@ -57,17 +56,8 @@ public enum DashXGql {
|
|
|
57
56
|
/// - quantity
|
|
58
57
|
/// - reset
|
|
59
58
|
/// - custom
|
|
60
|
-
public init(
|
|
61
|
-
graphQLMap = ["
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
public var accountType: Swift.Optional<String?> {
|
|
65
|
-
get {
|
|
66
|
-
return graphQLMap["accountType"] as? Swift.Optional<String?> ?? Swift.Optional<String?>.none
|
|
67
|
-
}
|
|
68
|
-
set {
|
|
69
|
-
graphQLMap.updateValue(newValue, forKey: "accountType")
|
|
70
|
-
}
|
|
59
|
+
public init(accountUid: Swift.Optional<String?> = nil, accountAnonymousUid: Swift.Optional<String?> = nil, itemId: UUID, pricingId: UUID, quantity: Decimal, reset: Bool, custom: Swift.Optional<JSON?> = nil) {
|
|
60
|
+
graphQLMap = ["accountUid": accountUid, "accountAnonymousUid": accountAnonymousUid, "itemId": itemId, "pricingId": pricingId, "quantity": quantity, "reset": reset, "custom": custom]
|
|
71
61
|
}
|
|
72
62
|
|
|
73
63
|
public var accountUid: Swift.Optional<String?> {
|
|
@@ -267,20 +257,10 @@ public enum DashXGql {
|
|
|
267
257
|
public var graphQLMap: GraphQLMap
|
|
268
258
|
|
|
269
259
|
/// - Parameters:
|
|
270
|
-
/// - accountType
|
|
271
260
|
/// - accountUid
|
|
272
261
|
/// - accountAnonymousUid
|
|
273
|
-
public init(
|
|
274
|
-
graphQLMap = ["
|
|
275
|
-
}
|
|
276
|
-
|
|
277
|
-
public var accountType: Swift.Optional<String?> {
|
|
278
|
-
get {
|
|
279
|
-
return graphQLMap["accountType"] as? Swift.Optional<String?> ?? Swift.Optional<String?>.none
|
|
280
|
-
}
|
|
281
|
-
set {
|
|
282
|
-
graphQLMap.updateValue(newValue, forKey: "accountType")
|
|
283
|
-
}
|
|
262
|
+
public init(accountUid: Swift.Optional<String?> = nil, accountAnonymousUid: Swift.Optional<String?> = nil) {
|
|
263
|
+
graphQLMap = ["accountUid": accountUid, "accountAnonymousUid": accountAnonymousUid]
|
|
284
264
|
}
|
|
285
265
|
|
|
286
266
|
public var accountUid: Swift.Optional<String?> {
|
|
@@ -385,7 +365,6 @@ public enum DashXGql {
|
|
|
385
365
|
public var graphQLMap: GraphQLMap
|
|
386
366
|
|
|
387
367
|
/// - Parameters:
|
|
388
|
-
/// - accountType
|
|
389
368
|
/// - uid
|
|
390
369
|
/// - anonymousUid
|
|
391
370
|
/// - email
|
|
@@ -393,17 +372,8 @@ public enum DashXGql {
|
|
|
393
372
|
/// - name
|
|
394
373
|
/// - firstName
|
|
395
374
|
/// - lastName
|
|
396
|
-
public init(
|
|
397
|
-
graphQLMap = ["
|
|
398
|
-
}
|
|
399
|
-
|
|
400
|
-
public var accountType: Swift.Optional<String?> {
|
|
401
|
-
get {
|
|
402
|
-
return graphQLMap["accountType"] as? Swift.Optional<String?> ?? Swift.Optional<String?>.none
|
|
403
|
-
}
|
|
404
|
-
set {
|
|
405
|
-
graphQLMap.updateValue(newValue, forKey: "accountType")
|
|
406
|
-
}
|
|
375
|
+
public init(uid: Swift.Optional<String?> = nil, anonymousUid: Swift.Optional<String?> = nil, email: Swift.Optional<String?> = nil, phone: Swift.Optional<String?> = nil, name: Swift.Optional<String?> = nil, firstName: Swift.Optional<String?> = nil, lastName: Swift.Optional<String?> = nil) {
|
|
376
|
+
graphQLMap = ["uid": uid, "anonymousUid": anonymousUid, "email": email, "phone": phone, "name": name, "firstName": firstName, "lastName": lastName]
|
|
407
377
|
}
|
|
408
378
|
|
|
409
379
|
public var uid: Swift.Optional<String?> {
|
|
@@ -583,20 +553,38 @@ public enum DashXGql {
|
|
|
583
553
|
public var graphQLMap: GraphQLMap
|
|
584
554
|
|
|
585
555
|
/// - Parameters:
|
|
586
|
-
/// -
|
|
556
|
+
/// - accountUid
|
|
557
|
+
/// - accountAnonymousUid
|
|
587
558
|
/// - name
|
|
588
559
|
/// - kind
|
|
589
560
|
/// - value
|
|
590
|
-
|
|
591
|
-
|
|
561
|
+
/// - userAgent
|
|
562
|
+
/// - osName
|
|
563
|
+
/// - osVersion
|
|
564
|
+
/// - deviceModel
|
|
565
|
+
/// - deviceManufacturer
|
|
566
|
+
/// - deviceUid
|
|
567
|
+
/// - deviceAdvertisingUid
|
|
568
|
+
/// - isDeviceAdTrackingEnabled
|
|
569
|
+
public init(accountUid: Swift.Optional<String?> = nil, accountAnonymousUid: Swift.Optional<String?> = nil, name: Swift.Optional<String?> = nil, kind: ContactKind, value: String, userAgent: Swift.Optional<String?> = nil, osName: Swift.Optional<String?> = nil, osVersion: Swift.Optional<String?> = nil, deviceModel: Swift.Optional<String?> = nil, deviceManufacturer: Swift.Optional<String?> = nil, deviceUid: Swift.Optional<String?> = nil, deviceAdvertisingUid: Swift.Optional<String?> = nil, isDeviceAdTrackingEnabled: Swift.Optional<Bool?> = nil) {
|
|
570
|
+
graphQLMap = ["accountUid": accountUid, "accountAnonymousUid": accountAnonymousUid, "name": name, "kind": kind, "value": value, "userAgent": userAgent, "osName": osName, "osVersion": osVersion, "deviceModel": deviceModel, "deviceManufacturer": deviceManufacturer, "deviceUid": deviceUid, "deviceAdvertisingUid": deviceAdvertisingUid, "isDeviceAdTrackingEnabled": isDeviceAdTrackingEnabled]
|
|
571
|
+
}
|
|
572
|
+
|
|
573
|
+
public var accountUid: Swift.Optional<String?> {
|
|
574
|
+
get {
|
|
575
|
+
return graphQLMap["accountUid"] as? Swift.Optional<String?> ?? Swift.Optional<String?>.none
|
|
576
|
+
}
|
|
577
|
+
set {
|
|
578
|
+
graphQLMap.updateValue(newValue, forKey: "accountUid")
|
|
579
|
+
}
|
|
592
580
|
}
|
|
593
581
|
|
|
594
|
-
public var
|
|
582
|
+
public var accountAnonymousUid: Swift.Optional<String?> {
|
|
595
583
|
get {
|
|
596
|
-
return graphQLMap["
|
|
584
|
+
return graphQLMap["accountAnonymousUid"] as? Swift.Optional<String?> ?? Swift.Optional<String?>.none
|
|
597
585
|
}
|
|
598
586
|
set {
|
|
599
|
-
graphQLMap.updateValue(newValue, forKey: "
|
|
587
|
+
graphQLMap.updateValue(newValue, forKey: "accountAnonymousUid")
|
|
600
588
|
}
|
|
601
589
|
}
|
|
602
590
|
|
|
@@ -626,43 +614,119 @@ public enum DashXGql {
|
|
|
626
614
|
graphQLMap.updateValue(newValue, forKey: "value")
|
|
627
615
|
}
|
|
628
616
|
}
|
|
617
|
+
|
|
618
|
+
public var userAgent: Swift.Optional<String?> {
|
|
619
|
+
get {
|
|
620
|
+
return graphQLMap["userAgent"] as? Swift.Optional<String?> ?? Swift.Optional<String?>.none
|
|
621
|
+
}
|
|
622
|
+
set {
|
|
623
|
+
graphQLMap.updateValue(newValue, forKey: "userAgent")
|
|
624
|
+
}
|
|
625
|
+
}
|
|
626
|
+
|
|
627
|
+
public var osName: Swift.Optional<String?> {
|
|
628
|
+
get {
|
|
629
|
+
return graphQLMap["osName"] as? Swift.Optional<String?> ?? Swift.Optional<String?>.none
|
|
630
|
+
}
|
|
631
|
+
set {
|
|
632
|
+
graphQLMap.updateValue(newValue, forKey: "osName")
|
|
633
|
+
}
|
|
634
|
+
}
|
|
635
|
+
|
|
636
|
+
public var osVersion: Swift.Optional<String?> {
|
|
637
|
+
get {
|
|
638
|
+
return graphQLMap["osVersion"] as? Swift.Optional<String?> ?? Swift.Optional<String?>.none
|
|
639
|
+
}
|
|
640
|
+
set {
|
|
641
|
+
graphQLMap.updateValue(newValue, forKey: "osVersion")
|
|
642
|
+
}
|
|
643
|
+
}
|
|
644
|
+
|
|
645
|
+
public var deviceModel: Swift.Optional<String?> {
|
|
646
|
+
get {
|
|
647
|
+
return graphQLMap["deviceModel"] as? Swift.Optional<String?> ?? Swift.Optional<String?>.none
|
|
648
|
+
}
|
|
649
|
+
set {
|
|
650
|
+
graphQLMap.updateValue(newValue, forKey: "deviceModel")
|
|
651
|
+
}
|
|
652
|
+
}
|
|
653
|
+
|
|
654
|
+
public var deviceManufacturer: Swift.Optional<String?> {
|
|
655
|
+
get {
|
|
656
|
+
return graphQLMap["deviceManufacturer"] as? Swift.Optional<String?> ?? Swift.Optional<String?>.none
|
|
657
|
+
}
|
|
658
|
+
set {
|
|
659
|
+
graphQLMap.updateValue(newValue, forKey: "deviceManufacturer")
|
|
660
|
+
}
|
|
661
|
+
}
|
|
662
|
+
|
|
663
|
+
public var deviceUid: Swift.Optional<String?> {
|
|
664
|
+
get {
|
|
665
|
+
return graphQLMap["deviceUid"] as? Swift.Optional<String?> ?? Swift.Optional<String?>.none
|
|
666
|
+
}
|
|
667
|
+
set {
|
|
668
|
+
graphQLMap.updateValue(newValue, forKey: "deviceUid")
|
|
669
|
+
}
|
|
670
|
+
}
|
|
671
|
+
|
|
672
|
+
public var deviceAdvertisingUid: Swift.Optional<String?> {
|
|
673
|
+
get {
|
|
674
|
+
return graphQLMap["deviceAdvertisingUid"] as? Swift.Optional<String?> ?? Swift.Optional<String?>.none
|
|
675
|
+
}
|
|
676
|
+
set {
|
|
677
|
+
graphQLMap.updateValue(newValue, forKey: "deviceAdvertisingUid")
|
|
678
|
+
}
|
|
679
|
+
}
|
|
680
|
+
|
|
681
|
+
public var isDeviceAdTrackingEnabled: Swift.Optional<Bool?> {
|
|
682
|
+
get {
|
|
683
|
+
return graphQLMap["isDeviceAdTrackingEnabled"] as? Swift.Optional<Bool?> ?? Swift.Optional<Bool?>.none
|
|
684
|
+
}
|
|
685
|
+
set {
|
|
686
|
+
graphQLMap.updateValue(newValue, forKey: "isDeviceAdTrackingEnabled")
|
|
687
|
+
}
|
|
688
|
+
}
|
|
629
689
|
}
|
|
630
690
|
|
|
631
691
|
public enum ContactKind: RawRepresentable, Equatable, Hashable, CaseIterable, Apollo.JSONDecodable, Apollo.JSONEncodable {
|
|
632
692
|
public typealias RawValue = String
|
|
633
|
-
case
|
|
634
|
-
case
|
|
693
|
+
case email
|
|
694
|
+
case phone
|
|
635
695
|
case ios
|
|
636
696
|
case android
|
|
697
|
+
case web
|
|
637
698
|
/// Auto generated constant for unknown enum values
|
|
638
699
|
case __unknown(RawValue)
|
|
639
700
|
|
|
640
701
|
public init?(rawValue: RawValue) {
|
|
641
702
|
switch rawValue {
|
|
642
|
-
case "
|
|
643
|
-
case "
|
|
703
|
+
case "EMAIL": self = .email
|
|
704
|
+
case "PHONE": self = .phone
|
|
644
705
|
case "IOS": self = .ios
|
|
645
706
|
case "ANDROID": self = .android
|
|
707
|
+
case "WEB": self = .web
|
|
646
708
|
default: self = .__unknown(rawValue)
|
|
647
709
|
}
|
|
648
710
|
}
|
|
649
711
|
|
|
650
712
|
public var rawValue: RawValue {
|
|
651
713
|
switch self {
|
|
652
|
-
case .
|
|
653
|
-
case .
|
|
714
|
+
case .email: return "EMAIL"
|
|
715
|
+
case .phone: return "PHONE"
|
|
654
716
|
case .ios: return "IOS"
|
|
655
717
|
case .android: return "ANDROID"
|
|
718
|
+
case .web: return "WEB"
|
|
656
719
|
case .__unknown(let value): return value
|
|
657
720
|
}
|
|
658
721
|
}
|
|
659
722
|
|
|
660
723
|
public static func == (lhs: ContactKind, rhs: ContactKind) -> Bool {
|
|
661
724
|
switch (lhs, rhs) {
|
|
662
|
-
case (.
|
|
663
|
-
case (.
|
|
725
|
+
case (.email, .email): return true
|
|
726
|
+
case (.phone, .phone): return true
|
|
664
727
|
case (.ios, .ios): return true
|
|
665
728
|
case (.android, .android): return true
|
|
729
|
+
case (.web, .web): return true
|
|
666
730
|
case (.__unknown(let lhsValue), .__unknown(let rhsValue)): return lhsValue == rhsValue
|
|
667
731
|
default: return false
|
|
668
732
|
}
|
|
@@ -670,10 +734,11 @@ public enum DashXGql {
|
|
|
670
734
|
|
|
671
735
|
public static var allCases: [ContactKind] {
|
|
672
736
|
return [
|
|
673
|
-
.
|
|
674
|
-
.
|
|
737
|
+
.email,
|
|
738
|
+
.phone,
|
|
675
739
|
.ios,
|
|
676
740
|
.android,
|
|
741
|
+
.web,
|
|
677
742
|
]
|
|
678
743
|
}
|
|
679
744
|
}
|
|
@@ -682,22 +747,12 @@ public enum DashXGql {
|
|
|
682
747
|
public var graphQLMap: GraphQLMap
|
|
683
748
|
|
|
684
749
|
/// - Parameters:
|
|
685
|
-
/// - accountType
|
|
686
750
|
/// - event
|
|
687
751
|
/// - accountUid
|
|
688
752
|
/// - accountAnonymousUid
|
|
689
753
|
/// - data
|
|
690
|
-
public init(
|
|
691
|
-
graphQLMap = ["
|
|
692
|
-
}
|
|
693
|
-
|
|
694
|
-
public var accountType: String {
|
|
695
|
-
get {
|
|
696
|
-
return graphQLMap["accountType"] as! String
|
|
697
|
-
}
|
|
698
|
-
set {
|
|
699
|
-
graphQLMap.updateValue(newValue, forKey: "accountType")
|
|
700
|
-
}
|
|
754
|
+
public init(event: String, accountUid: Swift.Optional<String?> = nil, accountAnonymousUid: Swift.Optional<String?> = nil, data: Swift.Optional<JSON?> = nil) {
|
|
755
|
+
graphQLMap = ["event": event, "accountUid": accountUid, "accountAnonymousUid": accountAnonymousUid, "data": data]
|
|
701
756
|
}
|
|
702
757
|
|
|
703
758
|
public var event: String {
|
package/ios/DashX.m
CHANGED
|
@@ -12,4 +12,5 @@ RCT_EXTERN_METHOD(searchContent:(NSString *)contentType options:(NSDictionary *)
|
|
|
12
12
|
RCT_EXTERN_METHOD(fetchContent:(NSString *)urn options:(NSDictionary *)options resolver:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject)
|
|
13
13
|
RCT_EXTERN_METHOD(addItemToCart:(NSString *)itemId pricingId:(NSString *)pricingId quantity:(NSString *)quantity reset:(BOOL)reset custom:(NSDictionary *)custom resolver:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject)
|
|
14
14
|
RCT_EXTERN_METHOD(fetchCart:resolver:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject)
|
|
15
|
+
RCT_EXTERN_METHOD(subscribe)
|
|
15
16
|
@end
|
package/ios/DashX.swift
CHANGED
|
@@ -23,10 +23,6 @@ class DashX: RCTEventEmitter {
|
|
|
23
23
|
func setup(_ options: NSDictionary?) {
|
|
24
24
|
ConfigInterceptor.shared.publicKey = options?.value(forKey: "publicKey") as? String
|
|
25
25
|
|
|
26
|
-
if let accountType = options?.value(forKey: "accountType") {
|
|
27
|
-
dashXClient.setAccountType(to: accountType as! String)
|
|
28
|
-
}
|
|
29
|
-
|
|
30
26
|
DashXAppDelegate.swizzleDidReceiveRemoteNotification()
|
|
31
27
|
|
|
32
28
|
if let baseUri = options?.value(forKey: "baseUri") {
|
|
@@ -145,4 +141,9 @@ class DashX: RCTEventEmitter {
|
|
|
145
141
|
)
|
|
146
142
|
}
|
|
147
143
|
|
|
144
|
+
@objc
|
|
145
|
+
func subscribe() {
|
|
146
|
+
dashXClient.subscribe()
|
|
147
|
+
}
|
|
148
|
+
|
|
148
149
|
}
|
package/ios/DashXClient.swift
CHANGED
|
@@ -10,7 +10,8 @@ class DashXClient {
|
|
|
10
10
|
private var anonymousUid: String?
|
|
11
11
|
private var uid: String?
|
|
12
12
|
private var deviceToken: String?
|
|
13
|
-
|
|
13
|
+
|
|
14
|
+
private var mustSubscribe: Bool = false;
|
|
14
15
|
|
|
15
16
|
private init() {
|
|
16
17
|
generateAnonymousUid()
|
|
@@ -18,10 +19,10 @@ class DashXClient {
|
|
|
18
19
|
|
|
19
20
|
func setDeviceToken(to: String) {
|
|
20
21
|
self.deviceToken = to
|
|
21
|
-
}
|
|
22
22
|
|
|
23
|
-
|
|
24
|
-
|
|
23
|
+
if (self.mustSubscribe) {
|
|
24
|
+
self.subscribe()
|
|
25
|
+
}
|
|
25
26
|
}
|
|
26
27
|
|
|
27
28
|
func setTargetEnvironment(to: String) {
|
|
@@ -64,7 +65,6 @@ class DashXClient {
|
|
|
64
65
|
self.uid = optionsDictionary?["uid"]
|
|
65
66
|
|
|
66
67
|
let identifyAccountInput = DashXGql.IdentifyAccountInput(
|
|
67
|
-
accountType: accountType,
|
|
68
68
|
uid: optionsDictionary?["uid"],
|
|
69
69
|
anonymousUid: anonymousUid,
|
|
70
70
|
email: optionsDictionary?["email"],
|
|
@@ -93,17 +93,11 @@ class DashXClient {
|
|
|
93
93
|
// MARK: -- track
|
|
94
94
|
|
|
95
95
|
func track(_ event: String, withData: NSDictionary?) {
|
|
96
|
-
if accountType == nil {
|
|
97
|
-
DashXLog.d(tag: #function, "AccountType not set skipping track()")
|
|
98
|
-
return
|
|
99
|
-
}
|
|
100
|
-
|
|
101
96
|
let trackEventInput = DashXGql.TrackEventInput(
|
|
102
|
-
accountType: accountType!,
|
|
103
97
|
event: event,
|
|
104
98
|
accountUid: uid,
|
|
105
99
|
accountAnonymousUid: anonymousUid,
|
|
106
|
-
data: withData as? [String:
|
|
100
|
+
data: withData as? [String: JSONDecodable?]
|
|
107
101
|
)
|
|
108
102
|
|
|
109
103
|
DashXLog.d(tag: #function, "Calling track with \(trackEventInput)")
|
|
@@ -128,14 +122,18 @@ class DashXClient {
|
|
|
128
122
|
// MARK: -- subscribe
|
|
129
123
|
|
|
130
124
|
func subscribe() {
|
|
131
|
-
if deviceToken == nil
|
|
125
|
+
if deviceToken == nil {
|
|
126
|
+
self.mustSubscribe = true
|
|
132
127
|
return
|
|
133
128
|
}
|
|
134
129
|
|
|
130
|
+
self.mustSubscribe = false
|
|
131
|
+
|
|
135
132
|
let deviceKind = "IOS"
|
|
136
133
|
|
|
137
134
|
let subscribeContactInput = DashXGql.SubscribeContactInput(
|
|
138
|
-
|
|
135
|
+
accountUid: uid,
|
|
136
|
+
accountAnonymousUid: anonymousUid!,
|
|
139
137
|
name: deviceKind,
|
|
140
138
|
kind: .ios,
|
|
141
139
|
value: deviceToken!
|
|
@@ -249,7 +247,7 @@ class DashXClient {
|
|
|
249
247
|
_ reject: @escaping RCTPromiseRejectBlock
|
|
250
248
|
) {
|
|
251
249
|
let addItemToCartInput = DashXGql.AddItemToCartInput(
|
|
252
|
-
|
|
250
|
+
accountUid: self.uid, accountAnonymousUid: self.anonymousUid, itemId: itemId, pricingId: pricingId, quantity: quantity, reset: reset, custom: custom as? [String: JSONDecodable?]
|
|
253
251
|
)
|
|
254
252
|
|
|
255
253
|
DashXLog.d(tag: #function, "Calling addItemToCart with \(addItemToCartInput)")
|
|
@@ -274,7 +272,7 @@ class DashXClient {
|
|
|
274
272
|
_ reject: @escaping RCTPromiseRejectBlock
|
|
275
273
|
) {
|
|
276
274
|
let fetchCartInput = DashXGql.FetchCartInput(
|
|
277
|
-
|
|
275
|
+
accountUid: self.uid, accountAnonymousUid: self.anonymousUid
|
|
278
276
|
)
|
|
279
277
|
|
|
280
278
|
DashXLog.d(tag: #function, "Calling fetchCart with \(fetchCartInput)")
|
package/ios/README.md
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
# iOS Native Module
|
|
2
|
+
|
|
3
|
+
## Development
|
|
4
|
+
|
|
5
|
+
### Obtaining Graphql schema and generating Graphql operation
|
|
6
|
+
|
|
7
|
+
- Make sure to install Apollo CLI via npm:
|
|
8
|
+
|
|
9
|
+
```sh
|
|
10
|
+
$ npm i -g apollo
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
- In order to generate code, Apollo requires local copy of Graphql schema, to download that:
|
|
14
|
+
|
|
15
|
+
```sh
|
|
16
|
+
$ apollo schema:download --endpoint="https://api.dashx.com/graphql" schema.json
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
This will save a `schama.json` file in your ios directory.
|
|
20
|
+
|
|
21
|
+
- Add Graphql request in `graphql` dir.
|
|
22
|
+
|
|
23
|
+
- Regenerate `API.swift` using:
|
|
24
|
+
|
|
25
|
+
```sh
|
|
26
|
+
$ apollo client:codegen --target=swift --namespace=DashXGql --localSchemaFile=schema.json --includes="graphql/*.graphql" --passthroughCustomScalars API.swift
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
For example, if you want to generate code for `FetchContent`.
|
|
30
|
+
|
|
31
|
+
- Download schema
|
|
32
|
+
|
|
33
|
+
```sh
|
|
34
|
+
$ apollo schema:download --endpoint="https://api.dashx.com/graphql" schema.json
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
- Add request in `graphql` dir with following contents:
|
|
38
|
+
|
|
39
|
+
```graphql
|
|
40
|
+
query FetchContent($input: FetchContentInput!) {
|
|
41
|
+
fetchContent(input: $input)
|
|
42
|
+
}
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
- Re-generate API.swift so it includes the `FetchContent` operation
|
|
46
|
+
|
|
47
|
+
```sh
|
|
48
|
+
$ apollo client:codegen --target=swift --namespace=DashXGql --localSchemaFile=schema.json --includes="graphql/*.graphql" --passthroughCustomScalars API.swift
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
- Now you can use FetchContent operation like so:
|
|
52
|
+
|
|
53
|
+
```swift
|
|
54
|
+
let fetchContentInput = DashXGql.FetchContentInput( // Note the DashXGql namespace
|
|
55
|
+
contentType: contentType,
|
|
56
|
+
content: content,
|
|
57
|
+
preview: preview,
|
|
58
|
+
language: language,
|
|
59
|
+
fields: fields,
|
|
60
|
+
include: include,
|
|
61
|
+
exclude: exclude
|
|
62
|
+
)
|
|
63
|
+
|
|
64
|
+
DashXLog.d(tag: #function, "Calling fetchContent with \(fetchContentInput)")
|
|
65
|
+
|
|
66
|
+
let fetchContentQuery = DashXGql.FetchContentQuery(input: fetchContentInput)
|
|
67
|
+
|
|
68
|
+
Network.shared.apollo.fetch(query: fetchContentQuery, cachePolicy: .returnCacheDataElseFetch) { result in
|
|
69
|
+
switch result {
|
|
70
|
+
case .success(let graphQLResult):
|
|
71
|
+
DashXLog.d(tag: #function, "Sent fetchContent with \(String(describing: graphQLResult))")
|
|
72
|
+
let content = graphQLResult.data?.fetchContent
|
|
73
|
+
resolve(content)
|
|
74
|
+
case .failure(let error):
|
|
75
|
+
DashXLog.d(tag: #function, "Encountered an error during fetchContent(): \(error)")
|
|
76
|
+
reject("", error.localizedDescription, error)
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
```
|
|
80
|
+
|