@dashx/react-native 0.1.11 → 0.1.12
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/ios/API.swift +13 -2
- package/ios/Constants.swift +1 -0
- package/ios/DashXClient.swift +12 -1
- package/ios/graphql/SubscribeContact.graphql +1 -0
- package/ios/schema.json +933 -682
- package/package.json +1 -1
package/ios/API.swift
CHANGED
|
@@ -2169,6 +2169,7 @@ public enum DashXGql {
|
|
|
2169
2169
|
subscribeContact(input: $input) {
|
|
2170
2170
|
__typename
|
|
2171
2171
|
id
|
|
2172
|
+
value
|
|
2172
2173
|
}
|
|
2173
2174
|
}
|
|
2174
2175
|
"""
|
|
@@ -2220,6 +2221,7 @@ public enum DashXGql {
|
|
|
2220
2221
|
return [
|
|
2221
2222
|
GraphQLField("__typename", type: .nonNull(.scalar(String.self))),
|
|
2222
2223
|
GraphQLField("id", type: .nonNull(.scalar(UUID.self))),
|
|
2224
|
+
GraphQLField("value", type: .nonNull(.scalar(String.self))),
|
|
2223
2225
|
]
|
|
2224
2226
|
}
|
|
2225
2227
|
|
|
@@ -2229,8 +2231,8 @@ public enum DashXGql {
|
|
|
2229
2231
|
self.resultMap = unsafeResultMap
|
|
2230
2232
|
}
|
|
2231
2233
|
|
|
2232
|
-
public init(id: UUID) {
|
|
2233
|
-
self.init(unsafeResultMap: ["__typename": "Contact", "id": id])
|
|
2234
|
+
public init(id: UUID, value: String) {
|
|
2235
|
+
self.init(unsafeResultMap: ["__typename": "Contact", "id": id, "value": value])
|
|
2234
2236
|
}
|
|
2235
2237
|
|
|
2236
2238
|
public var __typename: String {
|
|
@@ -2250,6 +2252,15 @@ public enum DashXGql {
|
|
|
2250
2252
|
resultMap.updateValue(newValue, forKey: "id")
|
|
2251
2253
|
}
|
|
2252
2254
|
}
|
|
2255
|
+
|
|
2256
|
+
public var value: String {
|
|
2257
|
+
get {
|
|
2258
|
+
return resultMap["value"]! as! String
|
|
2259
|
+
}
|
|
2260
|
+
set {
|
|
2261
|
+
resultMap.updateValue(newValue, forKey: "value")
|
|
2262
|
+
}
|
|
2263
|
+
}
|
|
2253
2264
|
}
|
|
2254
2265
|
}
|
|
2255
2266
|
}
|
package/ios/Constants.swift
CHANGED
|
@@ -3,6 +3,7 @@ import Foundation
|
|
|
3
3
|
struct Constants {
|
|
4
4
|
static let PACKAGE_NAME = "com.dashx.sdk"
|
|
5
5
|
static let USER_PREFERENCES_KEY_ANONYMOUS_UID = "\(PACKAGE_NAME).anonymous_uid"
|
|
6
|
+
static let USER_PREFERENCES_KEY_DEVICE_TOKEN = "\(PACKAGE_NAME).device_token"
|
|
6
7
|
static let USER_PREFERENCES_KEY_BUILD = "\(PACKAGE_NAME).build"
|
|
7
8
|
static let INTERNAL_EVENT_APP_INSTALLED = "Application Installed"
|
|
8
9
|
static let INTERNAL_EVENT_APP_UPDATED = "Application Updated"
|
package/ios/DashXClient.swift
CHANGED
|
@@ -131,6 +131,14 @@ class DashXClient {
|
|
|
131
131
|
|
|
132
132
|
let deviceKind = "IOS"
|
|
133
133
|
|
|
134
|
+
let preferences = UserDefaults.standard
|
|
135
|
+
let deviceTokenKey = Constants.USER_PREFERENCES_KEY_DEVICE_TOKEN
|
|
136
|
+
|
|
137
|
+
if preferences.string(forKey: deviceTokenKey) == deviceToken {
|
|
138
|
+
DashXLog.d(tag: #function, "Already subscribed: \(String(describing: deviceToken))")
|
|
139
|
+
return
|
|
140
|
+
}
|
|
141
|
+
|
|
134
142
|
let subscribeContactInput = DashXGql.SubscribeContactInput(
|
|
135
143
|
accountUid: uid,
|
|
136
144
|
accountAnonymousUid: anonymousUid!,
|
|
@@ -146,7 +154,10 @@ class DashXClient {
|
|
|
146
154
|
Network.shared.apollo.perform(mutation: subscribeContactMutation) { result in
|
|
147
155
|
switch result {
|
|
148
156
|
case .success(let graphQLResult):
|
|
149
|
-
|
|
157
|
+
if graphQLResult.data != nil {
|
|
158
|
+
preferences.set(graphQLResult.data?.subscribeContact.value, forKey: deviceTokenKey)
|
|
159
|
+
DashXLog.d(tag: #function, "Sent subscribe with \(String(describing: graphQLResult))")
|
|
160
|
+
}
|
|
150
161
|
case .failure(let error):
|
|
151
162
|
DashXLog.d(tag: #function, "Encountered an error during subscribe(): \(error)")
|
|
152
163
|
}
|