react-native-mytatva-rn-sdk 1.2.81 → 1.2.82

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.
@@ -341,7 +341,11 @@ class ConnectSensorActivity : BaseBleActivity() {
341
341
  Log.d("ConnectSensor", "Device verification API response: $response")
342
342
 
343
343
  val verificationResponse = Gson().fromJson(response, DeviceVerificationResponse::class.java)
344
- val code = verificationResponse.code
344
+ val code = when (val rawCode = verificationResponse.code) {
345
+ is Number -> rawCode.toInt()
346
+ is String -> rawCode.toIntOrNull() ?: 0
347
+ else -> 0
348
+ }
345
349
  val data = verificationResponse.data
346
350
  val msg = verificationResponse.msg
347
351
 
@@ -353,9 +357,9 @@ class ConnectSensorActivity : BaseBleActivity() {
353
357
  Log.d("ConnectSensor", "Device verification successful for sensor: $scannedSensorId")
354
358
  bind(device)
355
359
  } else if (code == 1 && data == false) {
356
- // Device verification failed - show API message in red
360
+ // Device verification failed - show fixed message in red
357
361
  Log.e("ConnectSensor", "Device verification failed: $msg")
358
- manageDeviceVerificationError(msg)
362
+ manageDeviceVerificationError("Please connect with Diasens sensor")
359
363
  } else {
360
364
  // code 0 or unexpected - show Try Again
361
365
  Log.e("ConnectSensor", "Device verification error, code: $code")
@@ -1,7 +1,7 @@
1
1
  package com.mytatvarnsdk.model
2
2
 
3
3
  data class DeviceVerificationResponse(
4
- val code: Int,
4
+ val code: Any?,
5
5
  val msg: String,
6
6
  val data: Any?
7
7
  )
@@ -368,7 +368,12 @@ class API {
368
368
  return
369
369
  }
370
370
 
371
- let code = json["code"] as? Int ?? 0
371
+ var code = 0
372
+ if let intCode = json["code"] as? Int {
373
+ code = intCode
374
+ } else if let strCode = json["code"] as? String, let parsed = Int(strCode) {
375
+ code = parsed
376
+ }
372
377
  let msg = json["msg"] as? String ?? ""
373
378
  let dataValue = json["data"] as? Bool ?? false
374
379
 
@@ -281,9 +281,9 @@ class ConnectToSensorViewController: UIViewController {
281
281
  self.viewModel.debouncer.update(with: .connected)
282
282
  self.showConfirmInsulinUser()
283
283
  } else if code == 1 && dataValue == false {
284
- // Device verification failed - show API message in red
284
+ // Device verification failed - show fixed message in red
285
285
  print("Device verification failed: \(msg)")
286
- self.showDeviceVerificationError(message: msg)
286
+ self.showDeviceVerificationError(message: "Please connect with Diasens sensor")
287
287
  } else {
288
288
  // code 0 or unexpected - show Try Again
289
289
  print("Device verification error, code: \(code)")
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-mytatva-rn-sdk",
3
- "version": "1.2.81",
3
+ "version": "1.2.82",
4
4
  "description": "a package to inject data into visit health pwa",
5
5
  "main": "lib/commonjs/index",
6
6
  "module": "lib/module/index",