react-native-move-sdk 2.14.0-1 → 2.14.1

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.
@@ -17,6 +17,7 @@ import com.movesdk.shared.ARGUMENT_STATE
17
17
  import com.movesdk.shared.BATTERY_OPTIMIZATION_REQUEST_CODE
18
18
  import com.movesdk.shared.EVENT_AUTH_BATTERY_PERMISSION
19
19
  import com.movesdk.shared.EVENT_AUTH_OVERLAY_PERMISSION
20
+ import com.movesdk.shared.LOG_TAG
20
21
  import com.movesdk.shared.OVERLAY_REQUEST_CODE
21
22
  import io.dolphin.move.MoveSdk
22
23
  import io.dolphin.move.MoveServiceWarning
@@ -48,70 +49,88 @@ class MoveSdkModule(context: ReactApplicationContext) : ReactContextBaseJavaModu
48
49
 
49
50
  @ReactMethod
50
51
  fun setup(
51
- userId: String,
52
- accessToken: String,
53
- refreshToken: String,
54
- projectId: Int,
55
- // Config
56
- timelineDetectionServices: ReadableArray,
57
- drivingServices: ReadableArray,
58
- walkingServices: ReadableArray,
52
+ auth: ReadableMap?,
53
+ config: ReadableMap?,
59
54
  options: ReadableMap?,
60
- // Platform config
61
- recognitionNotificationTitle: String,
62
- recognitionNotificationText: String,
63
- tripNotificationTitle: String,
64
- tripNotificationText: String,
55
+ platformParams: ReadableArray?,
65
56
  promise: Promise?
66
57
  ) {
67
- nativeSdkWrapper.setup(
68
- userId,
69
- accessToken,
70
- refreshToken,
71
- projectId,
72
- // Config
73
- timelineDetectionServices,
74
- drivingServices,
75
- walkingServices,
76
- options,
77
- // Platform config
78
- recognitionNotificationTitle,
79
- recognitionNotificationText,
80
- tripNotificationTitle,
81
- tripNotificationText,
82
- promise = promise
83
- )
58
+ try {
59
+ val authMap = auth?.toHashMap() ?: throw IllegalArgumentException("Auth object is null")
60
+ val userId = authMap["userId"] as String
61
+ val accessToken = authMap["accessToken"] as String
62
+ val refreshToken = authMap["refreshToken"] as String
63
+ val projectId = authMap["projectId"] as Double
64
+
65
+ config ?: throw IllegalArgumentException("Config object is null")
66
+ val timelineDetectionServices = config.getArray("timelineDetectionServices")!!
67
+ val drivingServices = config.getArray("drivingServices")!!
68
+ val walkingServices = config.getArray("walkingServices")!!
69
+
70
+ val platformParamsIterator = platformParams?.toArrayList()?.iterator()
71
+ ?: throw IllegalArgumentException("Platform Params object is null")
72
+ val recognitionNotificationTitle = platformParamsIterator.next() as String
73
+ val recognitionNotificationText = platformParamsIterator.next() as String
74
+ val tripNotificationTitle = platformParamsIterator.next() as String
75
+ val tripNotificationText = platformParamsIterator.next() as String
76
+
77
+ nativeSdkWrapper.setup(
78
+ userId = userId,
79
+ accessToken = accessToken,
80
+ refreshToken = refreshToken,
81
+ projectId = projectId.toInt(),
82
+ timelineDetectionServices = timelineDetectionServices,
83
+ drivingServices = drivingServices,
84
+ walkingServices = walkingServices,
85
+ options = options,
86
+ recognitionNotificationTitle = recognitionNotificationTitle,
87
+ recognitionNotificationText = recognitionNotificationText,
88
+ tripNotificationTitle = tripNotificationTitle,
89
+ tripNotificationText = tripNotificationText,
90
+ promise = promise
91
+ )
92
+ } catch (e: Exception) {
93
+ Log.e(LOG_TAG, "Error during setup", e)
94
+ }
84
95
  }
85
96
 
86
97
  @ReactMethod
87
98
  fun setupWithCode(
88
- code: String,
89
- // Config
90
- timelineDetectionServices: ReadableArray,
91
- drivingServices: ReadableArray,
92
- walkingServices: ReadableArray,
99
+ code: String?,
100
+ config: ReadableMap?,
93
101
  options: ReadableMap?,
94
- // Platform config
95
- recognitionNotificationTitle: String,
96
- recognitionNotificationText: String,
97
- tripNotificationTitle: String,
98
- tripNotificationText: String,
102
+ platformParams: ReadableArray?,
99
103
  promise: Promise?
100
104
  ) {
101
- nativeSdkWrapper.setup(
102
- code,
103
- // Config
104
- timelineDetectionServices,
105
- drivingServices,
106
- walkingServices,
107
- options,
108
- // Platform config
109
- recognitionNotificationTitle,
110
- recognitionNotificationText,
111
- tripNotificationTitle,
112
- tripNotificationText,
113
- promise = promise
114
- )
105
+ try {
106
+ code ?: throw IllegalArgumentException("Code is null")
107
+ config ?: throw IllegalArgumentException("Config object is null")
108
+ val timelineDetectionServices = config.getArray("timelineDetectionServices")!!
109
+ val drivingServices = config.getArray("drivingServices")!!
110
+ val walkingServices = config.getArray("walkingServices")!!
111
+
112
+ val platformParamsIterator = platformParams?.toArrayList()?.iterator()
113
+ ?: throw IllegalArgumentException("Platform Params object is null")
114
+ val recognitionNotificationTitle = platformParamsIterator.next() as String
115
+ val recognitionNotificationText = platformParamsIterator.next() as String
116
+ val tripNotificationTitle = platformParamsIterator.next() as String
117
+ val tripNotificationText = platformParamsIterator.next() as String
118
+
119
+ nativeSdkWrapper.setup(
120
+ code = code,
121
+ timelineDetectionServices = timelineDetectionServices,
122
+ drivingServices = drivingServices,
123
+ walkingServices = walkingServices,
124
+ options = options,
125
+ recognitionNotificationTitle = recognitionNotificationTitle,
126
+ recognitionNotificationText = recognitionNotificationText,
127
+ tripNotificationTitle = tripNotificationTitle,
128
+ tripNotificationText = tripNotificationText,
129
+ promise = promise
130
+ )
131
+ } catch (e: Exception) {
132
+ Log.e(LOG_TAG, "Error during setup", e)
133
+ }
115
134
  }
116
135
 
117
136
  @ReactMethod
@@ -334,17 +353,19 @@ class MoveSdkModule(context: ReactApplicationContext) : ReactContextBaseJavaModu
334
353
 
335
354
  @ReactMethod
336
355
  fun updateConfig(
337
- timelineDetectionServices: ReadableArray,
338
- drivingServices: ReadableArray,
339
- walkingServices: ReadableArray,
340
- options: ReadableMap?,
356
+ config: ReadableMap?,
357
+ options: ReadableMap?
341
358
  ) {
342
- nativeSdkWrapper.updateConfig(
343
- timelineDetectionServices,
344
- drivingServices,
345
- walkingServices,
346
- options
347
- )
359
+ try {
360
+ nativeSdkWrapper.updateConfig(
361
+ timelineDetectionServices = config?.getArray("timelineDetectionServices")!!,
362
+ drivingServices = config.getArray("drivingServices")!!,
363
+ walkingServices = config.getArray("walkingServices")!!,
364
+ options
365
+ )
366
+ } catch (e: Exception) {
367
+ Log.e(LOG_TAG, "Error updating config", e)
368
+ }
348
369
  }
349
370
 
350
371
  @ReactMethod
@@ -213,7 +213,7 @@ class MoveSdkModule internal constructor(context: ReactApplicationContext) :
213
213
  val userId = authMap["userId"] as String
214
214
  val accessToken = authMap["accessToken"] as String
215
215
  val refreshToken = authMap["refreshToken"] as String
216
- val projectId = authMap["projectId"] as Int
216
+ val projectId = authMap["projectId"] as Double
217
217
 
218
218
  config ?: throw IllegalArgumentException("Config object is null")
219
219
  val timelineDetectionServices = config.getArray("timelineDetectionServices")!!
@@ -231,7 +231,7 @@ class MoveSdkModule internal constructor(context: ReactApplicationContext) :
231
231
  userId = userId,
232
232
  accessToken = accessToken,
233
233
  refreshToken = refreshToken,
234
- projectId = projectId,
234
+ projectId = projectId.toInt(),
235
235
  timelineDetectionServices = timelineDetectionServices,
236
236
  drivingServices = drivingServices,
237
237
  walkingServices = walkingServices,
package/ios/MoveSdk.mm CHANGED
@@ -532,7 +532,7 @@ RCT_EXPORT_METHOD(updateConfig: (NSDictionary *)config
532
532
  id drivingServices = config[@"drivingServices"];
533
533
  id walkingServices = config[@"walkingServices"];
534
534
 
535
- [MoveSDKInstance.shared updateConfig: detectionServices drivingServices: drivingServices walkingServices: walkingServices, options: opt];
535
+ [MoveSDKInstance.shared updateConfig: detectionServices drivingServices: drivingServices walkingServices: walkingServices options: opt];
536
536
  }
537
537
 
538
538
  RCT_EXPORT_METHOD(getState: (RCTPromiseResolveBlock)resolve
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-move-sdk",
3
- "version": "2.14.0-1",
3
+ "version": "2.14.1",
4
4
  "description": "React Native library for MOVE SDK",
5
5
  "source": "./src/index.tsx",
6
6
  "main": "./lib/commonjs/index.js",