react-native-mytatva-rn-sdk 1.2.34 → 1.2.35

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 (27) hide show
  1. package/android/src/main/java/com/mytatvarnsdk/activity/SearchTransmitterActivity.kt +5 -1
  2. package/android/src/main/java/com/mytatvarnsdk/activity/StartCGMActivity.kt +0 -2
  3. package/android/src/main/res/color/radio_text_selector.xml +1 -1
  4. package/android/src/main/res/layout/activity_help.xml +0 -3
  5. package/android/src/main/res/values/styles.xml +103 -102
  6. package/ios/MyReactNativeBridge.m +113 -13
  7. package/ios/Storyboard/MainCGM.storyboard +44 -44
  8. package/ios/Support/Global.swift +11 -0
  9. package/ios/Support/GlobalYouTubePlayerView.swift +33 -0
  10. package/ios/TableViewCell/NoteTVC/NoteTVC.swift +37 -13
  11. package/ios/TableViewCell/NoteTVC/NoteTVC.xib +2 -2
  12. package/ios/TableViewCell/VIdeoTVC/VideoTVC.swift +10 -4
  13. package/ios/TableViewCell/WatchVideoTVC/WatchVideoTVC.swift +12 -0
  14. package/ios/TableViewCell/WatchVideoTVC/WatchVideoTVC.xib +11 -11
  15. package/ios/ViewControllers/AttachTransmitterViewController.swift +12 -0
  16. package/ios/ViewControllers/ChatWithExpertViewController.swift +1 -0
  17. package/ios/ViewControllers/ConnectToSensorViewController.swift +18 -0
  18. package/ios/ViewControllers/ConnectToTransmitterViewController.swift +15 -1
  19. package/ios/ViewControllers/ProvidePermissionViewController.swift +7 -0
  20. package/ios/ViewControllers/PutOnTheSensorViewController.swift +15 -1
  21. package/ios/ViewControllers/StartConnectionViewController.swift +12 -0
  22. package/ios/ViewModel/FinalViewModel.swift +138 -25
  23. package/ios/icon.xcassets/do_not_throw_sensor.imageset/Contents.json +23 -0
  24. package/ios/icon.xcassets/do_not_throw_sensor.imageset/image with cross.png +0 -0
  25. package/ios/icon.xcassets/do_not_throw_sensor.imageset/image with cross@2x.png +0 -0
  26. package/ios/icon.xcassets/do_not_throw_sensor.imageset/image with cross@3x.png +0 -0
  27. package/package.json +1 -1
@@ -70,6 +70,12 @@ class AttachTransmitterViewController: UIViewController {
70
70
  //self.navigationController?.pushViewController(vc, animated: true)
71
71
  }
72
72
 
73
+ customTopView.onDemoTapped = {
74
+ let webVC = WebViewController()
75
+ webVC.modalPresentationStyle = .formSheet
76
+ webVC.videoURL = URL(string: watchCGMVideo)
77
+ self.present(webVC, animated: true, completion: nil)
78
+ }
73
79
  customTopView.onCloseTapped = {
74
80
  let vc = ExitJourneyViewController.instantiate(fromStoryboard: Enum_stroyboard.Main.rawValue)
75
81
  vc.modalPresentationStyle = .overFullScreen
@@ -116,6 +122,12 @@ extension AttachTransmitterViewController: UITableViewDelegate, UITableViewDataS
116
122
  case .video:
117
123
  let cell: VideoTVC = tableView.dequeueReusableCell(for: indexPath)
118
124
  cell.imageViewBackground.image = loadImage(named: "step5")
125
+ cell.onPlayVideo = {
126
+ let webVC = WebViewController()
127
+ webVC.modalPresentationStyle = .formSheet
128
+ webVC.videoURL = URL(string: applyingTheSensor)
129
+ self.present(webVC, animated: true, completion: nil)
130
+ }
119
131
  return cell
120
132
  }
121
133
  }
@@ -6,6 +6,7 @@
6
6
  //
7
7
 
8
8
  import UIKit
9
+
9
10
  class ChatWithExpertViewController: UIViewController {
10
11
 
11
12
  @IBOutlet weak var tableView: UITableView!
@@ -28,6 +28,7 @@ class ConnectToSensorViewController: UIViewController {
28
28
 
29
29
  enum enumSuccessTableRow: Int, CaseIterable {
30
30
  case success
31
+ case note
31
32
  }
32
33
 
33
34
  enum enumFailureTableRow: Int, CaseIterable {
@@ -89,6 +90,12 @@ class ConnectToSensorViewController: UIViewController {
89
90
  self.navigationController?.pushViewController(vc, animated: false)
90
91
  }
91
92
 
93
+ customTopView.onDemoTapped = {
94
+ let webVC = WebViewController()
95
+ webVC.modalPresentationStyle = .formSheet
96
+ webVC.videoURL = URL(string: watchCGMVideo)
97
+ self.present(webVC, animated: true, completion: nil)
98
+ }
92
99
  customTopView.onCloseTapped = {
93
100
  let vc = ExitJourneyViewController.instantiate(fromStoryboard: Enum_stroyboard.Main.rawValue)
94
101
  vc.modalPresentationStyle = .overFullScreen
@@ -359,6 +366,11 @@ extension ConnectToSensorViewController: UITableViewDelegate, UITableViewDataSou
359
366
  cell.labelTitle.text = "Sensor Connected Successfully"
360
367
  cell.setImageForCGM()
361
368
  return cell
369
+
370
+ case .note:
371
+ let cell: NoteTVC = tableView.dequeueReusableCell(for: indexPath)
372
+ cell.setImportantNote(isFromSuccessConnection: true)
373
+ return cell
362
374
  }
363
375
  case .error:
364
376
  switch enumFailureTableRow(rawValue: indexPath.row)! {
@@ -382,6 +394,12 @@ extension ConnectToSensorViewController: UITableViewDelegate, UITableViewDataSou
382
394
  return cell
383
395
  case .watchVideo:
384
396
  let cell: WatchVideoTVC = tableView.dequeueReusableCell(for: indexPath)
397
+ cell.onPlayVideo = {
398
+ let webVC = WebViewController()
399
+ webVC.modalPresentationStyle = .formSheet
400
+ webVC.videoURL = URL(string: qrScanFailed)
401
+ self.present(webVC, animated: true, completion: nil)
402
+ }
385
403
  return cell
386
404
  }
387
405
  }
@@ -88,6 +88,7 @@ class ConnectToTransmitterViewController: UIViewController, KLTBluetoothDelegate
88
88
  contactSupport.buttonTapCallback = {
89
89
  }
90
90
 
91
+
91
92
  bottomButton.labelText = screenType == .error ? "Retry" : "Proceed"
92
93
 
93
94
  if screenType == .searching {
@@ -124,7 +125,13 @@ class ConnectToTransmitterViewController: UIViewController, KLTBluetoothDelegate
124
125
  }
125
126
  }
126
127
 
127
-
128
+ customTopView.onDemoTapped = {
129
+ let webVC = WebViewController()
130
+ webVC.modalPresentationStyle = .formSheet
131
+ webVC.videoURL = URL(string: watchCGMVideo)
132
+ self.present(webVC, animated: true, completion: nil)
133
+ }
134
+
128
135
  customTopView.onCloseTapped = {
129
136
  let vc = ExitJourneyViewController.instantiate(fromStoryboard: Enum_stroyboard.Main.rawValue)
130
137
  vc.modalPresentationStyle = .overFullScreen
@@ -336,6 +343,7 @@ extension ConnectToTransmitterViewController: UITableViewDelegate, UITableViewDa
336
343
  return cell
337
344
  case .importantNote:
338
345
  let cell: NoteTVC = tableView.dequeueReusableCell(for: indexPath)
346
+ cell.setImportantNote(isFromSuccessConnection: false)
339
347
  return cell
340
348
  }
341
349
  case .error:
@@ -359,6 +367,12 @@ extension ConnectToTransmitterViewController: UITableViewDelegate, UITableViewDa
359
367
  return cell
360
368
  case .watchVideo:
361
369
  let cell: WatchVideoTVC = tableView.dequeueReusableCell(for: indexPath)
370
+ cell.onPlayVideo = {
371
+ let webVC = WebViewController()
372
+ webVC.modalPresentationStyle = .formSheet
373
+ webVC.videoURL = URL(string: connectionJourneyError)
374
+ self.present(webVC, animated: true, completion: nil)
375
+ }
362
376
  return cell
363
377
  }
364
378
  }
@@ -49,6 +49,13 @@ class ProvidePermissionViewController: UIViewController {
49
49
  self.navigationController?.pushViewController(vc, animated: false)
50
50
  }
51
51
 
52
+ customTopView.onDemoTapped = {
53
+ let webVC = WebViewController()
54
+ webVC.modalPresentationStyle = .formSheet
55
+ webVC.videoURL = URL(string: watchCGMVideo)
56
+ self.present(webVC, animated: true, completion: nil)
57
+ }
58
+
52
59
  customTopView.onCloseTapped = {
53
60
  let vc = ExitJourneyViewController.instantiate(fromStoryboard: Enum_stroyboard.Main.rawValue)
54
61
  vc.modalPresentationStyle = .overFullScreen
@@ -41,6 +41,13 @@ class PutOnTheSensorViewController: UIViewController {
41
41
  self.navigationController?.pushViewController(vc, animated: false)
42
42
  }
43
43
 
44
+ customTopView.onDemoTapped = {
45
+ let webVC = WebViewController()
46
+ webVC.modalPresentationStyle = .formSheet
47
+ webVC.videoURL = URL(string: watchCGMVideo)
48
+ self.present(webVC, animated: true, completion: nil)
49
+ }
50
+
44
51
  customTopView.onCloseTapped = {
45
52
  let vc = ExitJourneyViewController.instantiate(fromStoryboard: Enum_stroyboard.Main.rawValue)
46
53
  vc.modalPresentationStyle = .overFullScreen
@@ -87,10 +94,17 @@ extension PutOnTheSensorViewController: UITableViewDelegate, UITableViewDataSour
87
94
  case .video:
88
95
  let cell: VideoTVC = tableView.dequeueReusableCell(for: indexPath)
89
96
  cell.imageViewBackground.image = loadImage(named: "step4")
97
+ cell.onPlayVideo = {
98
+ let webVC = WebViewController()
99
+ webVC.modalPresentationStyle = .formSheet
100
+ webVC.videoURL = URL(string: applyingTheSensor)
101
+ self.present(webVC, animated: true, completion: nil)
102
+ }
90
103
  return cell
91
104
  case .importantNote:
92
105
  let cell: NoteTVC = tableView.dequeueReusableCell(for: indexPath)
93
- cell.labelDesc.text = "Don’t unlock your sensor before putting it the sensor on your skin"
106
+ cell.setImportantNote()
107
+ // cell.labelDesc.text = "Don’t unlock your sensor before putting it the sensor on your skin"
94
108
  cell.imageViewLeft.isHidden = true
95
109
  cell.heightConstraint.constant = 64
96
110
  return cell
@@ -6,12 +6,16 @@
6
6
  //
7
7
 
8
8
  import UIKit
9
+ import WebKit
9
10
 
10
11
  class StartConnectionViewController: UIViewController {
11
12
 
12
13
  @IBOutlet weak var customTopView: CustomTopUIView!
13
14
  @IBOutlet weak var tableView: UITableView!
14
15
  @IBOutlet weak var startConnectionJourneyButton: CustomOverlayButton!
16
+ @objc var isForReconnect: Bool = false
17
+ var webView: WKWebView!
18
+
15
19
 
16
20
  enum enumTableRow: Int, CaseIterable {
17
21
  case separator
@@ -43,6 +47,14 @@ class StartConnectionViewController: UIViewController {
43
47
  self.navigationController?.pushViewController(vc, animated: false)
44
48
  }
45
49
 
50
+ customTopView.onDemoTapped = {
51
+ let webVC = WebViewController()
52
+ webVC.modalPresentationStyle = .formSheet // or .pageSheet, .fullScreen
53
+ webVC.videoURL = URL(string: watchCGMVideo)
54
+ self.present(webVC, animated: true, completion: nil)
55
+
56
+ }
57
+
46
58
  customTopView.onCloseTapped = {
47
59
  let vc = ExitJourneyViewController.instantiate(fromStoryboard: Enum_stroyboard.Main.rawValue)
48
60
  vc.modalPresentationStyle = .overFullScreen
@@ -14,11 +14,121 @@ import Foundation
14
14
  super.init()
15
15
  viewModel.initialize()
16
16
  }
17
- @objc public func callForObserveTransmitterUnbindStatus() {
18
- let sensorID = UserDefaults.standard.string(forKey: "sensorId") ?? ""
19
- if !sensorID.isEmpty {
20
- viewModel.getStatus()
17
+
18
+ // @objc public func callForObserveTransmitterUnbindStatus() {
19
+ // let sensorID = UserDefaults.standard.string(forKey: "sensorId") ?? ""
20
+ // if !sensorID.isEmpty {
21
+ // viewModel.getStatus()
22
+ // }
23
+ // }
24
+
25
+ @objc public func callForObserveTransmitterUnbindStatusWithCompletion(
26
+ _ completion: @escaping (_ finalResponse: [String: Any]?, _ error: Error?) -> Void
27
+ ) {
28
+ // Load JSON data from UserDefaults
29
+ guard let data = UserDefaults.standard.data(forKey: "CGMStatusItem") else {
30
+ let error = NSError(
31
+ domain: "SensorData",
32
+ code: 404,
33
+ userInfo: [NSLocalizedDescriptionKey: "No cached response found"]
34
+ )
35
+ completion(nil, error)
36
+ return
37
+ }
38
+
39
+ do {
40
+ let json = try JSONSerialization.jsonObject(with: data, options: [])
41
+ // Forward to actual handler, which includes a safety check
42
+ self.callForObserveTransmitterUnbindStatusWithResponse(json, completion: completion)
43
+ } catch {
44
+ completion(nil, NSError(domain: "SensorData", code: 405, userInfo: [NSLocalizedDescriptionKey: "Failed to parse cached JSON"]))
45
+ }
46
+ }
47
+
48
+
49
+ @objc public func callForObserveTransmitterUnbindStatusWithResponse(
50
+ _ response: Any, // Changed from [String: Any] to Any to add type safety
51
+ completion: @escaping (_ finalResponse: [String: Any]?, _ error: Error?) -> Void
52
+ ) {
53
+ // Ensure response is a dictionary
54
+ guard let responseDict = response as? [String: Any] else {
55
+ let error = NSError(
56
+ domain: "SensorData",
57
+ code: 406,
58
+ userInfo: [NSLocalizedDescriptionKey: "Response is not a dictionary"]
59
+ )
60
+ completion(nil, error)
61
+ return
62
+ }
63
+
64
+ guard let status = responseDict["status"] as? String, status == "success",
65
+ let dataArray = responseDict["data"] as? [[String: Any]],
66
+ let data = dataArray.first else {
67
+ let error = NSError(
68
+ domain: "SensorData",
69
+ code: 400,
70
+ userInfo: [NSLocalizedDescriptionKey: "Invalid status or missing data"]
71
+ )
72
+ completion(nil, error)
73
+ return
74
+ }
75
+
76
+ guard let sensorId = data["sensorId"] as? String,
77
+ let startDate = data["startDate"] as? String,
78
+ let endDate = data["endDate"] as? String,
79
+ let statusValue = data["status"] as? String,
80
+ let daysToExpire = data["daysToExpire"] as? Int else {
81
+ let error = NSError(
82
+ domain: "SensorData",
83
+ code: 401,
84
+ userInfo: [NSLocalizedDescriptionKey: "Missing or invalid sensor data in 'data'"]
85
+ )
86
+ completion(nil, error)
87
+ return
88
+ }
89
+
90
+ let baseResponse: [String: Any] = [
91
+ "sensorId": sensorId,
92
+ "startDate": startDate,
93
+ "endDate": endDate,
94
+ "status": statusValue,
95
+ "daysToExpire": daysToExpire
96
+ ]
97
+
98
+ let finalResponse = self.evaluateUnbindStatus(response: baseResponse, startDate: startDate, endDate: endDate)
99
+ completion(finalResponse, nil)
100
+ }
101
+
102
+ // MARK: - Main Logic
103
+ @objc public func evaluateUnbindStatus(
104
+ response: [String: Any],
105
+ startDate: String,
106
+ endDate: String
107
+ ) -> [String: Any] {
108
+ let updatedResponse = response
109
+
110
+ if viewModel.isCurrentDateInRange(startDate: startDate, endDate: endDate) {
111
+ print("Current date is in range")
112
+ if ((viewModel.manager.connectedPeripheral == nil) && !KLTLocalSettingManager.shareInstance().canConnectOtherDevice) {
113
+ viewModel.manager.startScan()
114
+ viewModel.debouncer.update(with: .disconnected)
115
+ } else {
116
+ print("here")
117
+ //debouncer.update(with: .connected)
118
+ //API.shared.sendStatus(status: .connected) 计算 算法入参
119
+ if let last = viewModel.manager.currentDevice { }
120
+ else {
121
+ //self.manager.closeBleSensor()
122
+ //manager.startScan()
123
+ //self.debouncer.update(with: .disconnected)
124
+ //debouncer.update(with: .transmitterDisconnectBox)
125
+ }
126
+ }
127
+ // if KLTBluetoothManager.shared().currentDevice.initialEndDate != nil {
128
+ //
21
129
  }
130
+
131
+ return updatedResponse
22
132
  }
23
133
  }
24
134
 
@@ -62,6 +172,7 @@ class FinalViewModel: NSObject {
62
172
  }
63
173
  }
64
174
  }
175
+
65
176
  func getStatus(encryptionKey: String = PROD_ENC_KEY,
66
177
  encryptionIv: String = PROD_ENC_IV) {
67
178
  print("ios token:", TOKEN)
@@ -173,18 +284,18 @@ class FinalViewModel: NSObject {
173
284
  countdownTimer?.invalidate()
174
285
  countdownTimer = nil
175
286
  }
176
-
177
287
  countdownTimer = Timer.scheduledTimer(timeInterval: 1.0, target: self, selector: #selector(countdown), userInfo: nil, repeats: true)
178
-
288
+
179
289
  }
180
290
  }
181
291
  } else {
182
292
  // no device is connected
293
+ print("no device is connected")
183
294
  }
184
-
185
-
295
+
186
296
  addAllObservers()
187
297
  }
298
+
188
299
  func addAllObservers() {
189
300
  manager.addObserver(self, forKeyPath: "status", options: .new, context: nil)
190
301
 
@@ -195,7 +306,6 @@ class FinalViewModel: NSObject {
195
306
  NotificationCenter.default.addObserver(self, selector: #selector(handleLatestReceiveData(_:)), name: NSNotification.Name(KLTAlertCurrentInInitialNotify), object: nil)
196
307
 
197
308
  NotificationCenter.default.addObserver(self, selector: #selector(updateData(_:)), name: NSNotification.Name(KLTUpdateDataNotify), object: nil)
198
-
199
309
  }
200
310
 
201
311
  func removeAllObservers() {
@@ -208,7 +318,6 @@ class FinalViewModel: NSObject {
208
318
  NotificationCenter.default.removeObserver(self, name: NSNotification.Name(KLTAlertCurrentInInitialNotify), object: nil)
209
319
 
210
320
  NotificationCenter.default.removeObserver(self, name: NSNotification.Name(KLTUpdateDataNotify), object: nil)
211
-
212
321
  }
213
322
 
214
323
 
@@ -303,6 +412,7 @@ class FinalViewModel: NSObject {
303
412
  }
304
413
  }
305
414
  }
415
+
306
416
  @objc func bluetoothEnable(_ notification: Notification) {
307
417
  if let isBluetoothEnabled = notification.object as? Bool {
308
418
  if !isBluetoothEnabled {
@@ -314,6 +424,7 @@ class FinalViewModel: NSObject {
314
424
  manager.startScan()
315
425
  }
316
426
  }
427
+
317
428
  @objc func countdown() {
318
429
  if let last = KLTDatabaseHandler.shared().isLatestDeviceDisconnected() {
319
430
  if let beginDate = KLTDateFormatter.shared.getDateFromWholeString(last.initialBeginDate ?? "") {
@@ -339,6 +450,7 @@ class FinalViewModel: NSObject {
339
450
  print(String.getTimeString(with: Int(totalSeconds)))
340
451
  //countDownValueLabel.text =
341
452
  }
453
+
342
454
  override func observeValue(
343
455
  forKeyPath keyPath: String?,
344
456
  of object: Any?,
@@ -350,11 +462,11 @@ class FinalViewModel: NSObject {
350
462
  let status = BluetoothManagerStatus(rawValue: newValue) else {
351
463
  return
352
464
  }
353
-
465
+
354
466
  print("===>device status is -> \(status)")
355
-
467
+
356
468
  switch status {
357
-
469
+
358
470
  case .disconnected:
359
471
  if KLTLocalSettingManager.shareInstance().canConnectOtherDevice {
360
472
  // Unbind then disconnect
@@ -368,11 +480,11 @@ class FinalViewModel: NSObject {
368
480
  print("===>device is disconnected")
369
481
  debouncer.update(with: CGMConnectionStatus.disconnected)
370
482
  case .tryToConnect:
371
- // if UserDefaults.standard.integer(forKey: "bgmode") != 1 {
372
- // DispatchQueue.main.asyncAfter(deadline: .now() + 20) {
373
- // self.manager.startScan()
374
- // }
375
- // }
483
+ // if UserDefaults.standard.integer(forKey: "bgmode") != 1 {
484
+ // DispatchQueue.main.asyncAfter(deadline: .now() + 20) {
485
+ // self.manager.startScan()
486
+ // }
487
+ // }
376
488
  break
377
489
  case .connected:
378
490
  if let timer = startScanTimer {
@@ -383,13 +495,13 @@ class FinalViewModel: NSObject {
383
495
  print("===>device is connected")
384
496
  debouncer.update(with: CGMConnectionStatus.connected)
385
497
  case .timeOut:
386
- // if !KLTLocalSettingManager.shareInstance().canConnectOtherDevice {
387
- // startScanTimer = Timer.scheduledTimer(timeInterval: 20,
388
- // target: self,
389
- // selector: #selector(startScan),
390
- // userInfo: nil,
391
- // repeats: false)
392
- // }
498
+ // if !KLTLocalSettingManager.shareInstance().canConnectOtherDevice {
499
+ // startScanTimer = Timer.scheduledTimer(timeInterval: 20,
500
+ // target: self,
501
+ // selector: #selector(startScan),
502
+ // userInfo: nil,
503
+ // repeats: false)
504
+ // }
393
505
  print("===>time out")
394
506
  break
395
507
  case .sensorLostPower:
@@ -407,6 +519,7 @@ class FinalViewModel: NSObject {
407
519
  break
408
520
  }
409
521
  }
522
+
410
523
  func sensorLostPower() {
411
524
  DispatchQueue.main.asyncAfter(deadline: .now() + 0.2) {
412
525
  // Will trigger `BluetoothManagerStatusDisconnected` due to forced disconnection
@@ -0,0 +1,23 @@
1
+ {
2
+ "images" : [
3
+ {
4
+ "filename" : "image with cross.png",
5
+ "idiom" : "universal",
6
+ "scale" : "1x"
7
+ },
8
+ {
9
+ "filename" : "image with cross@2x.png",
10
+ "idiom" : "universal",
11
+ "scale" : "2x"
12
+ },
13
+ {
14
+ "filename" : "image with cross@3x.png",
15
+ "idiom" : "universal",
16
+ "scale" : "3x"
17
+ }
18
+ ],
19
+ "info" : {
20
+ "author" : "xcode",
21
+ "version" : 1
22
+ }
23
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-mytatva-rn-sdk",
3
- "version": "1.2.34",
3
+ "version": "1.2.35",
4
4
  "description": "a package to inject data into visit health pwa",
5
5
  "main": "lib/commonjs/index",
6
6
  "module": "lib/module/index",