react-native-move-sdk 0.1.0

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.
Files changed (38) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +159 -0
  3. package/android/.project +17 -0
  4. package/android/build.gradle +145 -0
  5. package/android/gradle/wrapper/gradle-wrapper.jar +0 -0
  6. package/android/gradle/wrapper/gradle-wrapper.properties +5 -0
  7. package/android/gradle.properties +4 -0
  8. package/android/gradlew +183 -0
  9. package/android/gradlew.bat +100 -0
  10. package/android/src/main/AndroidManifest.xml +3 -0
  11. package/android/src/main/java/in/dolph/move/sdk/MoveNotificationConfig.kt +41 -0
  12. package/android/src/main/java/in/dolph/move/sdk/MoveSdkConfig.kt +18 -0
  13. package/android/src/main/java/in/dolph/move/sdk/MoveSdkModule.kt +293 -0
  14. package/android/src/main/java/in/dolph/move/sdk/MoveSdkPackage.kt +19 -0
  15. package/android/src/main/java/in/dolph/move/sdk/MoveSdkRepository.kt +194 -0
  16. package/android/src/main/java/in/dolph/move/sdk/NativeMoveSdkWrapper.kt +305 -0
  17. package/android/src/main/res/drawable-anydpi-v24/ic_notification.xml +13 -0
  18. package/android/src/main/res/drawable-hdpi/ic_notification.png +0 -0
  19. package/android/src/main/res/drawable-mdpi/ic_notification.png +0 -0
  20. package/android/src/main/res/drawable-xhdpi/ic_notification.png +0 -0
  21. package/android/src/main/res/drawable-xxhdpi/ic_notification.png +0 -0
  22. package/android/src/main/res/values/strings.xml +9 -0
  23. package/android/src/main/strings.xml +0 -0
  24. package/ios/MoveSdk-Bridging-Header.h +2 -0
  25. package/ios/MoveSdk.xcodeproj/project.pbxproj +289 -0
  26. package/ios/MoveSdk.xcodeproj/project.xcworkspace/contents.xcworkspacedata +4 -0
  27. package/ios/MoveSdk.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +8 -0
  28. package/ios/NativeModule/DolphinSdk.h +58 -0
  29. package/ios/NativeModule/DolphinSdk.swift +353 -0
  30. package/ios/NativeModule/DolphinSdkDemoReactNative-Bridging-Header.h +8 -0
  31. package/lib/commonjs/index.js +280 -0
  32. package/lib/commonjs/index.js.map +1 -0
  33. package/lib/module/index.js +269 -0
  34. package/lib/module/index.js.map +1 -0
  35. package/lib/typescript/index.d.ts +98 -0
  36. package/package.json +135 -0
  37. package/react-native-move-sdk.podspec +20 -0
  38. package/src/index.ts +407 -0
@@ -0,0 +1,58 @@
1
+ #import <Foundation/Foundation.h>
2
+
3
+ #import <React/RCTBridgeModule.h>
4
+ #import <React/RCTEventEmitter.h>
5
+
6
+ @interface DolphinSdkInternal: RCTEventEmitter
7
+ +(void)initIfPossibleWithLaunchOptions:(NSDictionary *) launchOptions;
8
+ -(void)sendAppEvent:(NSString *) eventInfo;
9
+ @end
10
+
11
+
12
+ @interface RCT_EXTERN_MODULE(DolphinSdk, DolphinSdkInternal)
13
+
14
+ RCT_EXTERN_METHOD(initialize: (NSString *)contractId
15
+ accessToken: (NSString *)accessToken
16
+ refreshToken: (NSString *)refreshToken
17
+ productId: (NSInteger *)productId
18
+ timelineDetectionServices: (NSArray<NSString> *)timelineDetectionServices
19
+ drivingServices: (NSArray<NSString> *)drivingServices
20
+ walkingServices: (NSArray<NSString> *)walkingServices
21
+ otherServices: (NSArray<NSString> *)otherServices
22
+ resolve: (RCTPromiseResolveBlock)resolve
23
+ reject: (RCTPromiseRejectBlock)reject
24
+ )
25
+
26
+ RCT_EXTERN_METHOD(getState: (RCTPromiseResolveBlock)resolve
27
+ rejecter: (RCTPromiseRejectBlock)reject)
28
+
29
+ RCT_EXTERN_METHOD(getTripState: (RCTPromiseResolveBlock)resolve
30
+ rejecter: (RCTPromiseRejectBlock)reject)
31
+
32
+ RCT_EXTERN_METHOD(startAutomaticDetection)
33
+
34
+ RCT_EXTERN_METHOD(stopAutomaticDetection)
35
+
36
+ RCT_EXTERN_METHOD(shutdown)
37
+
38
+ RCT_EXTERN_METHOD(forceTripRecognition)
39
+
40
+ RCT_EXTERN_METHOD(synchronizeUserData)
41
+
42
+ RCT_EXTERN_METHOD(ignoreCurrentTrip)
43
+
44
+ RCT_EXTERN_METHOD(finishCurrentTrip)
45
+
46
+ RCT_EXTERN_METHOD(getAuthState: (RCTPromiseResolveBlock)resolve
47
+ rejecter: (RCTPromiseRejectBlock)reject)
48
+
49
+ RCT_EXTERN_METHOD(updateAuth: (NSString *)contractId
50
+ accessToken: (NSString *)accessToken
51
+ refreshToken: (NSString *)refreshToken
52
+ productId: (NSInteger *)productId
53
+ resolver: (RCTPromiseResolveBlock)resolve
54
+ rejecter: (RCTPromiseRejectBlock)reject)
55
+
56
+ RCT_EXTERN_METHOD(resolveError)
57
+
58
+ @end
@@ -0,0 +1,353 @@
1
+ import Foundation
2
+ import DolphinMoveSDK
3
+
4
+ internal protocol DolphinSDKLauncherDelegate: AnyObject {
5
+ func send(event: DolphinSDKLauncher.Event, data: [String: Any])
6
+ }
7
+
8
+ @objc(DolphinSdk)
9
+ class DolphinSdk: RCTEventEmitter {
10
+ private enum CError: String, Error {
11
+ case transformedServices = "Unknown driving service identifier in init parameters"
12
+ case transformedTimelineDetectionServices = "Unknown timeline service identifier in init parameters"
13
+ case transformedWalkingServices = "Unknown walking service identifier in init parameters"
14
+ case transformedOtherServices = "Unknown other service identifier in init parameters"
15
+ }
16
+
17
+ var ERROR_CODE = "DOLPHIN_SDK_ERROR"
18
+
19
+ override init() {
20
+ super.init()
21
+ DolphinSDKLauncher.shared.delegate = self
22
+ }
23
+
24
+ @objc
25
+ func initialize(_ contractId: String,
26
+ accessToken: String,
27
+ refreshToken: String,
28
+ productId: Int64,
29
+ timelineDetectionServices: Array<String>,
30
+ drivingServices: Array<String>,
31
+ walkingServices: Array<String>,
32
+ otherServices: Array<String>,
33
+ resolve: @escaping RCTPromiseResolveBlock,
34
+ reject: @escaping RCTPromiseRejectBlock) {
35
+
36
+ do {
37
+
38
+ let transformedServices: Array<MoveConfig.DrivingService> = try drivingServices.map {(s) -> MoveConfig.DrivingService in
39
+ if(s == "DistractionFreeDriving") {
40
+ return MoveConfig.DrivingService.dfd
41
+ }
42
+ else if(s == "DrivingBehaviour") {
43
+ return MoveConfig.DrivingService.behaviour
44
+ }
45
+ else {
46
+ throw CError.transformedServices
47
+ }
48
+ }
49
+
50
+ let transformedTimelineDetectionServices: Array<MoveConfig.TimelineDetectionService> = try! timelineDetectionServices.map {(s) -> MoveConfig.TimelineDetectionService in
51
+ if(s == "DRIVING") {
52
+ return MoveConfig.TimelineDetectionService.driving
53
+ }
54
+ else if(s == "BICYCLE") {
55
+ return MoveConfig.TimelineDetectionService.bicycle
56
+ }
57
+ else if(s == "WALKING") {
58
+ return MoveConfig.TimelineDetectionService.walking
59
+ }
60
+ else if(s == "PUBLIC_TRANSPORT") {
61
+ return MoveConfig.TimelineDetectionService.publicTransport
62
+ }
63
+ else {
64
+ throw CError.transformedTimelineDetectionServices
65
+ }
66
+ }
67
+
68
+ let transformedWalkingServices: Array<MoveConfig.WalkingService> = try walkingServices.map {(s) -> MoveConfig.WalkingService in
69
+ if(s == "Location") {
70
+ return MoveConfig.WalkingService.location
71
+ }
72
+ else {
73
+ throw CError.transformedWalkingServices
74
+ }
75
+ }
76
+
77
+ let transformedOtherServices: Array<MoveConfig.OtherService> = try otherServices.map {(s) -> MoveConfig.OtherService in
78
+ if(s == "PointsOfInterest") {
79
+ return MoveConfig.OtherService.poi
80
+ }
81
+ else {
82
+ throw CError.transformedOtherServices
83
+ }
84
+ }
85
+
86
+ // TODO: Fix wrapper and add config option from RN for walking services (actually only 1 now)
87
+ let sdkConfig = MoveConfig(timelineDetectionService: transformedTimelineDetectionServices, drivingServices: transformedServices, walkingServices: transformedWalkingServices, otherServices: transformedOtherServices)
88
+ let auth = MoveAuth(userToken: accessToken, refreshToken: refreshToken, contractID: contractId, productID: productId)
89
+
90
+ DispatchQueue.main.async {
91
+ DolphinSDKLauncher.shared.initialize(auth: auth, config: sdkConfig)
92
+ }
93
+ resolve("OK")
94
+ } catch {
95
+ reject("DOLPHIN_SDK_ERROR", "\(error)", nil)
96
+ }
97
+ }
98
+
99
+ @objc
100
+ func getState(
101
+ _ resolve: RCTPromiseResolveBlock,
102
+ rejecter reject: RCTPromiseRejectBlock
103
+ ) {
104
+ resolve("\(DolphinSDKLauncher.shared.sdk.getSDKState())")
105
+ }
106
+
107
+ @objc
108
+ func getAuthState(
109
+ _ resolve: RCTPromiseResolveBlock,
110
+ rejecter reject: RCTPromiseRejectBlock
111
+ ) {
112
+ resolve("\(DolphinSDKLauncher.shared.sdk.getAuthState())")
113
+ }
114
+
115
+ @objc
116
+ func updateAuth(
117
+ _ contractId: String,
118
+ accessToken: String,
119
+ refreshToken: String,
120
+ productId: Int64,
121
+ resolver resolve: @escaping RCTPromiseResolveBlock,
122
+ rejecter reject: @escaping RCTPromiseRejectBlock
123
+ ) {
124
+ let auth = MoveAuth(userToken: accessToken, refreshToken: refreshToken, contractID: contractId, productID: productId)
125
+
126
+ DolphinSDKLauncher.shared.sdk.update(auth: auth) { configurationError in
127
+ if let configurationError = configurationError {
128
+ reject("DolphinSdk-AuthState-ConfigurationError", "\(configurationError)", nil)
129
+ } else {
130
+ DolphinSDKLauncher.shared.sdkAuth = auth
131
+ resolve("OK")
132
+ }
133
+ }
134
+ }
135
+
136
+ @objc
137
+ func getTripState(
138
+ _ resolve: RCTPromiseResolveBlock,
139
+ rejecter reject: RCTPromiseRejectBlock
140
+ ) {
141
+ resolve("\(DolphinSDKLauncher.shared.sdk.getTripState())")
142
+ }
143
+
144
+ @objc
145
+ func startAutomaticDetection() {
146
+ DolphinSDKLauncher.shared.startAutomaticDetection()
147
+ }
148
+
149
+ @objc
150
+ func stopAutomaticDetection() {
151
+ DolphinSDKLauncher.shared.stopAutomaticDetection()
152
+ }
153
+
154
+ @objc
155
+ func shutdown() {
156
+ DolphinSDKLauncher.shared.shutdown()
157
+ }
158
+
159
+ @objc
160
+ func forceTripRecognition() {
161
+ DolphinSDKLauncher.shared.sdk.forceTripRecognition()
162
+ }
163
+
164
+ @objc
165
+ func synchronizeUserData() {
166
+ DolphinSDKLauncher.shared.sdk.synchronizeUserData()
167
+ }
168
+
169
+ @objc
170
+ func ignoreCurrentTrip() {
171
+ DolphinSDKLauncher.shared.sdk.ignoreCurrentTrip()
172
+ }
173
+
174
+ @objc
175
+ func finishCurrentTrip() {
176
+ DolphinSDKLauncher.shared.sdk.finishCurrentTrip()
177
+ }
178
+
179
+ @objc
180
+ func resolveError() {
181
+ DolphinSDKLauncher.shared.sdk.resolveSDKStateError()
182
+ }
183
+
184
+ @objc
185
+ func sendAppEvent(_ eventInfo: NSString) {
186
+ self.sendEvent(withName: "DolphinSdk-AppEvent", body: ["eventInfo": "\(eventInfo)"])
187
+ }
188
+
189
+ @objc public static func initIfPossibleWith(launchOptions: [UIApplication.LaunchOptionsKey: Any]?) {
190
+ DolphinSDKLauncher.shared.initIfPossibleWith(launchOptions: launchOptions)
191
+ }
192
+
193
+ override func supportedEvents() -> [String]! {
194
+ return ["DolphinSdk-InitError", "DolphinSdk-State", "DolphinSdk-TripState", "DolphinSdk-AuthState", "DolphinSdk-AppEvent"]
195
+ }
196
+
197
+ static override func moduleName() -> String! {
198
+ return "DolphinSdk"
199
+ }
200
+
201
+ static override func requiresMainQueueSetup() -> Bool {
202
+ // To let React Native know if your module needs to be initialized on the main thread, before any JavaScript code executes.
203
+ // Otherwise you will see a warning that in the future your module may be initialized on a background thread unless you explicitly opt out
204
+ return true
205
+ }
206
+ }
207
+
208
+ extension DolphinSdk: DolphinSDKLauncherDelegate {
209
+ func send(event: DolphinSDKLauncher.Event, data: [String: Any]) {
210
+ sendEvent(withName: event.rawValue, body: data)
211
+ }
212
+ }
213
+
214
+ internal class DolphinSDKLauncher {
215
+ internal enum Event: String {
216
+ case sdkState = "DolphinSdk-State"
217
+ case tripState = "DolphinSdk-TripState"
218
+ case authState = "DolphinSdk-AuthState"
219
+ case initError = "DolphinSdk-InitError"
220
+ }
221
+
222
+ private enum DefaultsKey: String {
223
+ case auth = "MOVE.WRAPPER.AUTH"
224
+ case config = "MOVE.WRAPPER.CONFIG"
225
+ }
226
+
227
+ weak var delegate: DolphinSDKLauncherDelegate?
228
+
229
+ static let shared = DolphinSDKLauncher()
230
+
231
+ let sdk = MoveSDK.shared
232
+ var launchOptions: [UIApplication.LaunchOptionsKey: Any]?
233
+
234
+ /// Persistence
235
+ internal var sdkAuth: DolphinMoveSDK.MoveAuth? {
236
+ didSet { DolphinSDKLauncher.encode(sdkAuth, forKey: .auth) }
237
+ }
238
+
239
+ private var sdkConfig: DolphinMoveSDK.MoveConfig? {
240
+ didSet { DolphinSDKLauncher.encode(sdkConfig, forKey: .config) }
241
+ }
242
+
243
+ private var isInRunningState: Bool {
244
+ didSet {
245
+ UserDefaults.standard.set(isInRunningState, forKey: "MOVE.WRAPPER.RUNNING")
246
+ }
247
+ }
248
+
249
+ init() {
250
+ sdkConfig = DolphinSDKLauncher.decode(.config)
251
+ sdkAuth = DolphinSDKLauncher.decode(.auth)
252
+
253
+ isInRunningState = UserDefaults.standard.bool(forKey: "MOVE.WRAPPER.RUNNING")
254
+
255
+ sdk.setSDKStateListener { state in
256
+ var data = ["state": "\(state)"]
257
+ switch (state) {
258
+ case let .error(stateError):
259
+ data["errorReason"] = "\(stateError)"
260
+ case .ready:
261
+ if self.isInRunningState {
262
+ self.sdk.startAutomaticDetection()
263
+ }
264
+ default:
265
+ break;
266
+ }
267
+ self.delegate?.send(event: .sdkState, data: data)
268
+ }
269
+
270
+ sdk.setTripStateListener { state in
271
+ self.delegate?.send(event: .tripState, data: ["state": "\(state)"])
272
+ }
273
+
274
+ sdk.setAuthStateUpdateListener { state in
275
+ var data = ["state": "\(state)"]
276
+ switch (state) {
277
+ case let .valid(auth):
278
+ self.sdkAuth = auth
279
+ data["accessToken"] = "\(auth.userToken)"
280
+ data["refreshToken"] = "\(auth.refreshToken)"
281
+ default:
282
+ break
283
+ }
284
+
285
+ self.delegate?.send(event: .authState, data: data)
286
+ }
287
+ }
288
+
289
+ internal func initIfPossibleWith(launchOptions: [UIApplication.LaunchOptionsKey: Any]?) {
290
+ self.launchOptions = launchOptions
291
+ /// warm start SDK
292
+ if isInRunningState, let auth = sdkAuth, let config = sdkConfig {
293
+ MoveSDK.shared.initialize(auth: auth, config: config, launchOptions: launchOptions) { initError in
294
+ if let error = initError {
295
+ self.delegate?.send(event: .initError, data: ["error": "\(error)"])
296
+ }
297
+ }
298
+ }
299
+ }
300
+
301
+ internal func initialize(auth: DolphinMoveSDK.MoveAuth, config: DolphinMoveSDK.MoveConfig) {
302
+ MoveSDK.shared.initialize(auth: auth, config: config, launchOptions: self.launchOptions) { initError in
303
+ if let error = initError {
304
+ self.delegate?.send(event: .initError, data: ["error": "\(error)"])
305
+ } else {
306
+ /// store back config and auth for bg launch
307
+ self.sdkConfig = config
308
+ self.sdkAuth = auth
309
+ }
310
+ }
311
+ }
312
+
313
+ func shutdown() {
314
+ isInRunningState = false
315
+ sdkAuth = nil
316
+ sdk.shutDown()
317
+ }
318
+
319
+ func startAutomaticDetection() {
320
+ if !isInRunningState {
321
+ isInRunningState = true
322
+ sdk.startAutomaticDetection()
323
+ }
324
+ }
325
+
326
+ func stopAutomaticDetection() {
327
+ if isInRunningState {
328
+ isInRunningState = false
329
+ sdk.stopAutomaticDetection()
330
+ }
331
+ }
332
+
333
+ private static func decode<T>(_ key: DefaultsKey) -> T? where T: Decodable {
334
+ let decoder = PropertyListDecoder()
335
+
336
+ if let data = UserDefaults.standard.object(forKey: key.rawValue) as? Data {
337
+ return try? decoder.decode(T.self, from: data)
338
+ }
339
+
340
+ return nil
341
+ }
342
+
343
+ private static func encode<T>(_ encodable: T?, forKey key: DefaultsKey) where T: Encodable {
344
+ if let encodable = encodable {
345
+ let encoder = PropertyListEncoder()
346
+ if let data = try? encoder.encode(encodable) {
347
+ UserDefaults.standard.set(data, forKey: key.rawValue)
348
+ }
349
+ } else {
350
+ UserDefaults.standard.removeObject(forKey: key.rawValue)
351
+ }
352
+ }
353
+ }
@@ -0,0 +1,8 @@
1
+ //
2
+ // Use this file to import your target's public headers that you would like to expose to Swift.
3
+ //
4
+
5
+ #import "React/RCTBridgeModule.h"
6
+ #import "React/RCTEventEmitter.h"
7
+
8
+ #import <React/RCTBundleURLProvider.h>
@@ -0,0 +1,280 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+
8
+ var _reactNative = require("react-native");
9
+
10
+ function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
11
+
12
+ const {
13
+ DolphinSdk: NativeMoveSdk
14
+ } = _reactNative.NativeModules;
15
+ const eventEmitter = new _reactNative.NativeEventEmitter(NativeMoveSdk);
16
+
17
+ class MoveSdk {
18
+ static sdkStateFromNative(nativeSdkState) {
19
+ var _stateString;
20
+
21
+ let stateString = nativeSdkState === null || nativeSdkState === void 0 ? void 0 : nativeSdkState.toLowerCase();
22
+
23
+ if ((_stateString = stateString) !== null && _stateString !== void 0 && _stateString.includes('(')) {
24
+ var _stateString2, _stateString3;
25
+
26
+ stateString = (_stateString2 = stateString) === null || _stateString2 === void 0 ? void 0 : _stateString2.substring(0, (_stateString3 = stateString) === null || _stateString3 === void 0 ? void 0 : _stateString3.indexOf('(')).toLowerCase();
27
+ }
28
+
29
+ switch (stateString) {
30
+ case 'uninitialized':
31
+ return MoveSdk.UNINITIALIZED;
32
+
33
+ case 'ready':
34
+ return MoveSdk.READY;
35
+
36
+ case 'running':
37
+ return MoveSdk.RUNNING;
38
+
39
+ case 'error':
40
+ return MoveSdk.ERROR;
41
+
42
+ default:
43
+ return null;
44
+ }
45
+ }
46
+
47
+ static tripStateFromNative(nativeTripState) {
48
+ const state = nativeTripState === null || nativeTripState === void 0 ? void 0 : nativeTripState.toLowerCase();
49
+
50
+ if ([MoveSdk.UNKNOWN, MoveSdk.DRIVING, MoveSdk.HALT, MoveSdk.IDLE, MoveSdk.IGNORED].includes(state)) {
51
+ return state;
52
+ }
53
+
54
+ return null;
55
+ }
56
+
57
+ static authStateFromNative(nativeAuthState) {
58
+ const state = nativeAuthState === null || nativeAuthState === void 0 ? void 0 : nativeAuthState.toLowerCase();
59
+
60
+ if ([MoveSdk.AUTH_VALID, MoveSdk.AUTH_EXPIRED].includes(state)) {
61
+ return state;
62
+ }
63
+
64
+ return null;
65
+ }
66
+
67
+ static configurationErrorFromNative(nativeInitError) {
68
+ const state = nativeInitError === null || nativeInitError === void 0 ? void 0 : nativeInitError.toLowerCase();
69
+ return state;
70
+ }
71
+
72
+ static initialize(config, auth, android) {
73
+ const {
74
+ timelineDetectionServices,
75
+ drivingServices,
76
+ walkingServices,
77
+ otherServices
78
+ } = config;
79
+ const {
80
+ contractId,
81
+ productId,
82
+ accessToken,
83
+ refreshToken
84
+ } = auth;
85
+ let platformParams = [];
86
+
87
+ if (_reactNative.Platform.OS === 'android') {
88
+ const {
89
+ notifications,
90
+ allowMockLocations
91
+ } = android;
92
+ const {
93
+ tripNotification,
94
+ recognitionNotification
95
+ } = notifications;
96
+
97
+ if (!tripNotification || !recognitionNotification) {
98
+ throw new Error('MOVE SDK needs notification configuration for Android');
99
+ }
100
+
101
+ platformParams = [recognitionNotification.title, recognitionNotification.text, recognitionNotification.channel.id, recognitionNotification.channel.name, recognitionNotification.channel.description, tripNotification.title, tripNotification.text, tripNotification.channel.id, tripNotification.channel.name, tripNotification.channel.description, allowMockLocations];
102
+ }
103
+
104
+ NativeMoveSdk.initialize(contractId, accessToken, refreshToken, productId, // Config
105
+ timelineDetectionServices, drivingServices, walkingServices, otherServices, // Platform config
106
+ ...platformParams).catch(e => {
107
+ throw new Error(`Initialization failed, Exception occured with message ${e.message}`);
108
+ });
109
+ }
110
+
111
+ static resolveError() {
112
+ NativeMoveSdk.resolveError();
113
+ }
114
+
115
+ static updateAuth(auth) {
116
+ const {
117
+ contractId,
118
+ productId,
119
+ accessToken,
120
+ refreshToken
121
+ } = auth;
122
+ NativeMoveSdk.updateAuth(contractId, accessToken, refreshToken, productId);
123
+ }
124
+
125
+ static startAutomaticDetection() {
126
+ NativeMoveSdk.startAutomaticDetection();
127
+ }
128
+
129
+ static forceTripRecognition() {
130
+ NativeMoveSdk.forceTripRecognition();
131
+ }
132
+
133
+ static keepInForeground(enabled) {
134
+ if (_reactNative.Platform.OS === 'android') {
135
+ NativeMoveSdk.keepInForeground(enabled);
136
+ } else {
137
+ console.warn('MoveSdk.keepInForeground() is Android OS only.');
138
+ }
139
+ }
140
+
141
+ static keepActive(enabled) {
142
+ if (_reactNative.Platform.OS === 'android') {
143
+ NativeMoveSdk.keepActive(enabled);
144
+ } else {
145
+ console.warn('MoveSdk.keepActive() is Android OS only.');
146
+ }
147
+ }
148
+
149
+ static stopAutomaticDetection() {
150
+ NativeMoveSdk.stopAutomaticDetection();
151
+ }
152
+
153
+ static synchronizeUserData() {
154
+ NativeMoveSdk.synchronizeUserData();
155
+ }
156
+
157
+ static shutdown() {
158
+ NativeMoveSdk.shutdown();
159
+ }
160
+
161
+ static getAuthState() {
162
+ return new Promise((resolve, _reject) => {
163
+ NativeMoveSdk.getAuthState().then(nativeState => resolve(MoveSdk.authStateFromNative(nativeState)));
164
+ });
165
+ }
166
+
167
+ static getState() {
168
+ return new Promise((resolve, _reject) => {
169
+ NativeMoveSdk.getState().then(nativeState => resolve(MoveSdk.sdkStateFromNative(nativeState)));
170
+ });
171
+ }
172
+
173
+ static getTripState() {
174
+ return new Promise((resolve, _reject) => {
175
+ NativeMoveSdk.getTripState().then(nativeState => resolve(MoveSdk.tripStateFromNative(nativeState)));
176
+ });
177
+ }
178
+
179
+ static addTripStateListener(tripStateChanged) {
180
+ return eventEmitter.addListener('DolphinSdk-TripState', event => tripStateChanged(MoveSdk.tripStateFromNative(event.state)));
181
+ }
182
+
183
+ static addSDKStateListener(sdkStateChanged) {
184
+ return eventEmitter.addListener('DolphinSdk-State', event => {
185
+ const transformedEvent = { ...event,
186
+ state: MoveSdk.sdkStateFromNative(event.state)
187
+ };
188
+ sdkStateChanged(transformedEvent);
189
+ });
190
+ }
191
+
192
+ static addInitErrorListener(initErrorReceived) {
193
+ return eventEmitter.addListener('DolphinSdk-InitError', event => initErrorReceived(MoveSdk.configurationErrorFromNative(event.error)));
194
+ }
195
+
196
+ static addAuthStateListener(authStateChanged) {
197
+ return eventEmitter.addListener('DolphinSdk-AuthState', event => {
198
+ const transformedEvent = { ...event,
199
+ state: MoveSdk.authStateFromNative(event.state)
200
+ };
201
+ authStateChanged(transformedEvent);
202
+ });
203
+ }
204
+
205
+ static addAppEventListener(appEventReceived) {
206
+ return eventEmitter.addListener('DolphinSdk-AppEvent', event => {
207
+ appEventReceived(event);
208
+ });
209
+ }
210
+
211
+ static version() {
212
+ return _reactNative.Platform.OS === 'android' ? NativeMoveSdk.getConstants().version : 'Unknown';
213
+ }
214
+
215
+ static finishCurrentTrip() {
216
+ NativeMoveSdk.finishCurrentTrip();
217
+ }
218
+
219
+ static ignoreCurrentTrip() {
220
+ NativeMoveSdk.ignoreCurrentTrip();
221
+ } // **** PERMISSIONS MODULE START *****
222
+
223
+
224
+ static canDrawOverlays() {
225
+ return new Promise((resolve, _reject) => {
226
+ NativeMoveSdk.canDrawOverlays().then(result => resolve(result));
227
+ });
228
+ }
229
+
230
+ static requestDrawOverlaysPermission() {
231
+ if (_reactNative.Platform.OS === 'android') {
232
+ NativeMoveSdk.requestDrawOverlaysPermission();
233
+ } else {
234
+ console.warn('MoveSdk.requestAppIgnoringBatteryOptimization() is Android OS only.');
235
+ }
236
+ }
237
+
238
+ static isAppIgnoringBatteryOptimization() {
239
+ return new Promise((resolve, _reject) => {
240
+ NativeMoveSdk.isAppIgnoringBatteryOptimization().then(result => resolve(result));
241
+ });
242
+ }
243
+
244
+ static requestAppIgnoringBatteryOptimization() {
245
+ if (_reactNative.Platform.OS === 'android') {
246
+ NativeMoveSdk.requestAppIgnoringBatteryOptimization();
247
+ } else {
248
+ console.warn('MoveSdk.requestAppIgnoringBatteryOptimization() is Android OS only.');
249
+ }
250
+ } // **** PERMISSIONS MODULE END *****
251
+
252
+
253
+ }
254
+
255
+ exports.default = MoveSdk;
256
+
257
+ _defineProperty(MoveSdk, "ERROR", 'error');
258
+
259
+ _defineProperty(MoveSdk, "READY", 'ready');
260
+
261
+ _defineProperty(MoveSdk, "RUNNING", 'running');
262
+
263
+ _defineProperty(MoveSdk, "UNINITIALIZED", 'uninitialized');
264
+
265
+ _defineProperty(MoveSdk, "AUTH_INVALID", 'authinvalid');
266
+
267
+ _defineProperty(MoveSdk, "AUTH_EXPIRED", 'expired');
268
+
269
+ _defineProperty(MoveSdk, "AUTH_VALID", 'valid');
270
+
271
+ _defineProperty(MoveSdk, "UNKNOWN", 'unknown');
272
+
273
+ _defineProperty(MoveSdk, "DRIVING", 'driving');
274
+
275
+ _defineProperty(MoveSdk, "HALT", 'halt');
276
+
277
+ _defineProperty(MoveSdk, "IDLE", 'idle');
278
+
279
+ _defineProperty(MoveSdk, "IGNORED", 'ignored');
280
+ //# sourceMappingURL=index.js.map