react-native-mytatva-rn-sdk 1.2.39 → 1.2.41
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/android/src/main/AndroidManifestNew.xml +2 -1
- package/android/src/main/java/com/mytatvarnsdk/CgmTrackyLibModule.kt +29 -29
- package/android/src/main/java/com/mytatvarnsdk/activity/PlaceSensorActivity.kt +1 -1
- package/android/src/main/java/com/mytatvarnsdk/activity/PlaceTransmitterActivity.kt +1 -1
- package/android/src/main/java/com/mytatvarnsdk/activity/SearchTransmitterActivity.kt +1 -5
- package/android/src/main/java/com/mytatvarnsdk/activity/StartCGMActivity.kt +0 -1
- package/android/src/main/res/layout/activity_place_sensor.xml +0 -12
- package/android/src/main/res/layout/activity_place_transmitter.xml +0 -12
- package/ios/MyReactNativeBridge.m +70 -86
- package/ios/Support/API.swift +0 -1
- package/ios/Support/Global.swift +2 -1
- package/ios/TableViewCell/VIdeoTVC/VideoTVC.swift +1 -6
- package/ios/ViewControllers/AttachTransmitterViewController.swift +1 -1
- package/ios/ViewControllers/ConnectToSensorViewController.swift +10 -2
- package/ios/ViewControllers/StartConnectionViewController.swift +88 -4
- package/package.json +1 -1
|
@@ -124,7 +124,8 @@
|
|
|
124
124
|
|
|
125
125
|
<activity
|
|
126
126
|
android:name=".activity.VideoActivity"
|
|
127
|
-
android:
|
|
127
|
+
android:configChanges="orientation|screenSize|keyboardHidden|smallestScreenSize|screenLayout"
|
|
128
|
+
android:exported="false" />
|
|
128
129
|
|
|
129
130
|
<receiver
|
|
130
131
|
android:name=".receiver.BootCompleteReceiver"
|
|
@@ -70,8 +70,7 @@ class CgmTrackyLibModule(reactContext: ReactApplicationContext) :
|
|
|
70
70
|
private val apiScope = CoroutineScope(Dispatchers.IO + SupervisorJob())
|
|
71
71
|
private var debounceJob: Job? = null
|
|
72
72
|
|
|
73
|
-
|
|
74
|
-
private var lastDeviceStatus: PocDevice? = null
|
|
73
|
+
private var lastDeviceStatus: String? = null
|
|
75
74
|
|
|
76
75
|
private var glucoseObserver: Observer<PocGlucose?>? = null
|
|
77
76
|
private var isObserving = false
|
|
@@ -107,13 +106,9 @@ class CgmTrackyLibModule(reactContext: ReactApplicationContext) :
|
|
|
107
106
|
|
|
108
107
|
Handler(Looper.getMainLooper()).post {
|
|
109
108
|
mModel.device.observeForever { device ->
|
|
110
|
-
if (device != lastDeviceStatus) {
|
|
111
|
-
lastDeviceStatus = device
|
|
112
|
-
postEventDataToAPI(device, "", lastDeviceStatus?.qrMessage ?: "")
|
|
113
|
-
resetDebounceTimer()
|
|
114
|
-
}
|
|
115
|
-
|
|
116
109
|
if (device != null) {
|
|
110
|
+
postEventDataToAPI(device, "", device?.qrMessage ?: "")
|
|
111
|
+
|
|
117
112
|
Log.d("observeDeviceStatus: ", device.toString())
|
|
118
113
|
}
|
|
119
114
|
}
|
|
@@ -256,30 +251,36 @@ class CgmTrackyLibModule(reactContext: ReactApplicationContext) :
|
|
|
256
251
|
}
|
|
257
252
|
|
|
258
253
|
if (status.isNotEmpty()) {
|
|
259
|
-
|
|
260
|
-
put("transmitterName", device?.name ?: "")
|
|
261
|
-
put("SensorId", sensorId ?: "")
|
|
262
|
-
put("Sensor", sensorId ?: "")
|
|
263
|
-
put("timeInMillis", Date().time)
|
|
264
|
-
}
|
|
254
|
+
if (status !== lastDeviceStatus) {
|
|
265
255
|
|
|
266
|
-
|
|
267
|
-
put("sensorId", sensorId ?: "")
|
|
268
|
-
put("status", status)
|
|
269
|
-
put("rawData", rawData)
|
|
270
|
-
}
|
|
256
|
+
lastDeviceStatus = status
|
|
271
257
|
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
258
|
+
val rawData = JSONObject().apply {
|
|
259
|
+
put("transmitterName", device?.name ?: "")
|
|
260
|
+
put("SensorId", sensorId ?: "")
|
|
261
|
+
put("Sensor", sensorId ?: "")
|
|
262
|
+
put("timeInMillis", Date().time)
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
val obj = JSONObject().apply {
|
|
266
|
+
put("sensorId", sensorId ?: "")
|
|
267
|
+
put("status", status)
|
|
268
|
+
put("rawData", rawData)
|
|
279
269
|
}
|
|
280
|
-
)
|
|
281
|
-
}
|
|
282
270
|
|
|
271
|
+
authenticateSDKService.postDeviceData(
|
|
272
|
+
environment = if ("uat".uppercase() == "PROD") TATVA_ENVIRONMENT.PROD else TATVA_ENVIRONMENT.STAGE,
|
|
273
|
+
data = obj.toString(),
|
|
274
|
+
token = userToken,
|
|
275
|
+
loaderListener = object : LoaderListener {
|
|
276
|
+
override fun onShowLoader() {}
|
|
277
|
+
override fun onHideLoader() {}
|
|
278
|
+
}
|
|
279
|
+
)
|
|
280
|
+
|
|
281
|
+
resetDebounceTimer()
|
|
282
|
+
}
|
|
283
|
+
}
|
|
283
284
|
} catch (e: Exception) {
|
|
284
285
|
e.printStackTrace()
|
|
285
286
|
}
|
|
@@ -496,7 +497,6 @@ class CgmTrackyLibModule(reactContext: ReactApplicationContext) :
|
|
|
496
497
|
}
|
|
497
498
|
|
|
498
499
|
postEventDataToAPI(it, statusId, it.qrMessage)
|
|
499
|
-
resetDebounceTimer()
|
|
500
500
|
} ?: run {
|
|
501
501
|
Log.e(
|
|
502
502
|
"handleGlucoseError",
|
|
@@ -73,7 +73,7 @@ class PlaceSensorActivity : AppCompatActivity() {
|
|
|
73
73
|
|
|
74
74
|
binding.ivPlay.setOnClickListener {
|
|
75
75
|
startActivity(
|
|
76
|
-
Intent(this, VideoActivity::class.java).putExtra("VideoId", "
|
|
76
|
+
Intent(this, VideoActivity::class.java).putExtra("VideoId", "O01BBxzxGmE")
|
|
77
77
|
)
|
|
78
78
|
}
|
|
79
79
|
|
|
@@ -81,7 +81,7 @@ class PlaceTransmitterActivity : AppCompatActivity() {
|
|
|
81
81
|
|
|
82
82
|
binding.ivPlay.setOnClickListener {
|
|
83
83
|
startActivity(
|
|
84
|
-
Intent(this, VideoActivity::class.java).putExtra("VideoId", "
|
|
84
|
+
Intent(this, VideoActivity::class.java).putExtra("VideoId", "6m3pxl5BK9A")
|
|
85
85
|
)
|
|
86
86
|
}
|
|
87
87
|
|
|
@@ -531,11 +531,7 @@ class SearchTransmitterActivity : BaseBleActivity() {
|
|
|
531
531
|
|
|
532
532
|
Log.d("onDeviceConnect--->", "onDeviceConnect: " + transmitterDeviceInfo.toString())
|
|
533
533
|
if (enumDevice.getEnumDevice(transmitterDeviceInfo!!.pocDevice.name).isAbleScanQRCode) {
|
|
534
|
-
|
|
535
|
-
proceedToNextStep()
|
|
536
|
-
} else {
|
|
537
|
-
bindSuccess()
|
|
538
|
-
}
|
|
534
|
+
bindSuccess()
|
|
539
535
|
} else {
|
|
540
536
|
bind(transmitterDeviceInfo!!.pocDevice)
|
|
541
537
|
}
|
|
@@ -206,18 +206,6 @@
|
|
|
206
206
|
|
|
207
207
|
</androidx.cardview.widget.CardView>
|
|
208
208
|
|
|
209
|
-
<com.pierfrancescosoffritti.androidyoutubeplayer.core.player.views.YouTubePlayerView
|
|
210
|
-
android:id="@+id/youtube_player_view"
|
|
211
|
-
android:layout_width="match_parent"
|
|
212
|
-
android:layout_height="wrap_content"
|
|
213
|
-
android:layout_marginTop="24dp"
|
|
214
|
-
android:visibility="gone"
|
|
215
|
-
app:autoPlay="true"
|
|
216
|
-
app:layout_constraintEnd_toEndOf="parent"
|
|
217
|
-
app:layout_constraintStart_toStartOf="parent"
|
|
218
|
-
app:layout_constraintTop_toBottomOf="@id/tvInstructions"
|
|
219
|
-
app:videoId="r5Zemc4R044" />
|
|
220
|
-
|
|
221
209
|
<TextView
|
|
222
210
|
android:id="@+id/tvNote"
|
|
223
211
|
android:layout_width="match_parent"
|
|
@@ -205,18 +205,6 @@
|
|
|
205
205
|
|
|
206
206
|
</androidx.cardview.widget.CardView>
|
|
207
207
|
|
|
208
|
-
<com.pierfrancescosoffritti.androidyoutubeplayer.core.player.views.YouTubePlayerView
|
|
209
|
-
android:id="@+id/youtube_player_view"
|
|
210
|
-
android:layout_width="match_parent"
|
|
211
|
-
android:layout_height="wrap_content"
|
|
212
|
-
android:layout_marginTop="24dp"
|
|
213
|
-
android:visibility="gone"
|
|
214
|
-
app:autoPlay="true"
|
|
215
|
-
app:layout_constraintEnd_toEndOf="parent"
|
|
216
|
-
app:layout_constraintStart_toStartOf="parent"
|
|
217
|
-
app:layout_constraintTop_toBottomOf="@id/tvInstructions"
|
|
218
|
-
app:videoId="r5Zemc4R044" />
|
|
219
|
-
|
|
220
208
|
<include
|
|
221
209
|
android:id="@+id/commonButton"
|
|
222
210
|
layout="@layout/layout_button"
|
|
@@ -100,55 +100,24 @@ RCT_EXPORT_MODULE();
|
|
|
100
100
|
|
|
101
101
|
RCT_EXPORT_METHOD(startCgmTracky:(NSString *)token)
|
|
102
102
|
{
|
|
103
|
-
// NSLog(@"Received token: %@", token);
|
|
104
|
-
//
|
|
105
|
-
// // Save token
|
|
106
|
-
// [[NSUserDefaults standardUserDefaults] setObject:token forKey:@"authToken"];
|
|
107
|
-
// [[NSUserDefaults standardUserDefaults] synchronize];
|
|
108
|
-
//
|
|
109
|
-
//
|
|
110
|
-
// // Show native view
|
|
111
|
-
// dispatch_async(dispatch_get_main_queue(), ^{
|
|
112
|
-
// UIWindow *keyWindow = [UIApplication sharedApplication].delegate.window;
|
|
113
|
-
// UIViewController *rootVC = keyWindow.rootViewController;
|
|
114
|
-
//
|
|
115
|
-
// UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"MainCGM" bundle:nil];
|
|
116
|
-
// UIViewController *nativeVC = [storyboard instantiateViewControllerWithIdentifier:@"StartConnectionViewController"];
|
|
117
|
-
//
|
|
118
|
-
// if (nativeVC) {
|
|
119
|
-
// UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:nativeVC];
|
|
120
|
-
// navController.modalPresentationStyle = UIModalPresentationOverFullScreen;
|
|
121
|
-
// [rootVC presentViewController:navController animated:YES completion:nil];
|
|
122
|
-
// }
|
|
123
|
-
// });
|
|
124
|
-
|
|
125
103
|
NSLog(@"Received token: %@", token);
|
|
126
|
-
|
|
104
|
+
|
|
105
|
+
// Save token
|
|
127
106
|
[[NSUserDefaults standardUserDefaults] setObject:token forKey:@"authToken"];
|
|
128
107
|
[[NSUserDefaults standardUserDefaults] synchronize];
|
|
108
|
+
|
|
109
|
+
|
|
110
|
+
// Show native view
|
|
129
111
|
dispatch_async(dispatch_get_main_queue(), ^{
|
|
130
112
|
UIWindow *keyWindow = [UIApplication sharedApplication].delegate.window;
|
|
131
113
|
UIViewController *rootVC = keyWindow.rootViewController;
|
|
132
|
-
|
|
133
|
-
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"MainCGM" bundle:
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
reconnectVC.modalPresentationStyle = UIModalPresentationOverFullScreen;
|
|
140
|
-
// Set isForReconnect = YES
|
|
141
|
-
if ([reconnectVC respondsToSelector:@selector(setIsForReconnect:)]) {
|
|
142
|
-
[reconnectVC setValue:@(YES) forKey:@"isForReconnect"];
|
|
143
|
-
}
|
|
144
|
-
// Present it directly without navigation
|
|
145
|
-
// if (reconnectVC) {
|
|
146
|
-
// [rootVC presentViewController:reconnectVC animated:YES completion:nil];
|
|
147
|
-
// }
|
|
148
|
-
|
|
149
|
-
UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:reconnectVC];
|
|
150
|
-
navController.modalPresentationStyle = UIModalPresentationOverFullScreen;
|
|
151
|
-
if (reconnectVC) {
|
|
114
|
+
|
|
115
|
+
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"MainCGM" bundle:nil];
|
|
116
|
+
UIViewController *nativeVC = [storyboard instantiateViewControllerWithIdentifier:@"StartConnectionViewController"];
|
|
117
|
+
|
|
118
|
+
if (nativeVC) {
|
|
119
|
+
UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:nativeVC];
|
|
120
|
+
navController.modalPresentationStyle = UIModalPresentationOverFullScreen;
|
|
152
121
|
[rootVC presentViewController:navController animated:YES completion:nil];
|
|
153
122
|
}
|
|
154
123
|
});
|
|
@@ -169,7 +138,7 @@ RCT_EXPORT_METHOD(reconnectCgmTracky:(NSString *)token)
|
|
|
169
138
|
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"MainCGM" bundle:[NSBundle mainBundle]];
|
|
170
139
|
|
|
171
140
|
// Instantiate the target ViewController
|
|
172
|
-
UIViewController *reconnectVC = [storyboard instantiateViewControllerWithIdentifier:@"
|
|
141
|
+
UIViewController *reconnectVC = [storyboard instantiateViewControllerWithIdentifier:@"StartConnectionViewController"];
|
|
173
142
|
|
|
174
143
|
// Set presentation style
|
|
175
144
|
reconnectVC.modalPresentationStyle = UIModalPresentationOverFullScreen;
|
|
@@ -190,7 +159,6 @@ RCT_EXPORT_METHOD(reconnectCgmTracky:(NSString *)token)
|
|
|
190
159
|
});
|
|
191
160
|
}
|
|
192
161
|
|
|
193
|
-
|
|
194
162
|
RCT_EXPORT_METHOD(openHelpSupport)
|
|
195
163
|
{
|
|
196
164
|
dispatch_async(dispatch_get_main_queue(), ^{
|
|
@@ -243,52 +211,68 @@ RCT_EXPORT_METHOD(observeAllGlucoseData:(NSString *)token)
|
|
|
243
211
|
});
|
|
244
212
|
}
|
|
245
213
|
|
|
246
|
-
//
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
// [[NSUserDefaults standardUserDefaults] synchronize];
|
|
251
|
-
// FinalViewModelManager *manager = [FinalViewModelManager shared];
|
|
252
|
-
// [manager callForObserveTransmitterUnbindStatus];
|
|
253
|
-
//}
|
|
254
|
-
|
|
255
|
-
RCT_EXPORT_METHOD(observeTransmitterUnbindStatus:(NSString *)token response:(NSString *)responseJsonString)
|
|
214
|
+
// Internal method — can be kept private using a class extension
|
|
215
|
+
- (void)observeTransmitterUnbindStatus:(NSString *)token
|
|
216
|
+
response:(NSDictionary *)responseDict
|
|
217
|
+
completion:(void (^)(NSDictionary *response, NSError *error))completion
|
|
256
218
|
{
|
|
257
|
-
//
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
[
|
|
265
|
-
|
|
266
|
-
@"success": @NO,
|
|
267
|
-
@"error": @"Invalid JSON response from JS"
|
|
268
|
-
}];
|
|
269
|
-
return;
|
|
219
|
+
// Save token
|
|
220
|
+
[[NSUserDefaults standardUserDefaults] setObject:token forKey:@"authToken"];
|
|
221
|
+
[[NSUserDefaults standardUserDefaults] synchronize];
|
|
222
|
+
|
|
223
|
+
// Save CGM status item to UserDefaults (if needed by Swift)
|
|
224
|
+
NSData *jsonData = [NSJSONSerialization dataWithJSONObject:responseDict options:0 error:nil];
|
|
225
|
+
if (jsonData) {
|
|
226
|
+
[[NSUserDefaults standardUserDefaults] setObject:jsonData forKey:@"CGMStatusItem"];
|
|
227
|
+
[[NSUserDefaults standardUserDefaults] synchronize];
|
|
270
228
|
}
|
|
271
229
|
|
|
272
|
-
//
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
@"success": @NO,
|
|
278
|
-
@"error": error.localizedDescription ?: @"Unknown error"
|
|
279
|
-
};
|
|
280
|
-
[self sendEventWithName:@"observeTransmitterUnbindStatusHandler" body:errorPayload];
|
|
281
|
-
} else {
|
|
282
|
-
NSDictionary *successPayload = @{
|
|
283
|
-
@"token": token ?: @"",
|
|
284
|
-
@"responseFromBackend": response ?: @{},
|
|
285
|
-
@"responseFromJS": responseDict ?: @{},
|
|
286
|
-
@"success": @YES
|
|
287
|
-
};
|
|
288
|
-
[self sendEventWithName:@"observeTransmitterUnbindStatusHandler" body:successPayload];
|
|
230
|
+
// Call Swift method which reads CGMStatusItem from UserDefaults
|
|
231
|
+
FinalViewModelManager *manager = [FinalViewModelManager shared];
|
|
232
|
+
[manager callForObserveTransmitterUnbindStatusWithCompletion:^(NSDictionary *response, NSError *error) {
|
|
233
|
+
if (completion) {
|
|
234
|
+
completion(response, error);
|
|
289
235
|
}
|
|
290
236
|
}];
|
|
291
|
-
|
|
292
237
|
}
|
|
293
238
|
|
|
239
|
+
//RCT_EXPORT_METHOD(observeTransmitterUnbindStatus:(NSString *)token response:(NSString *)responseJsonString)
|
|
240
|
+
//{
|
|
241
|
+
// // Optional: Parse the JSON string if needed
|
|
242
|
+
// NSData *jsonData = [responseJsonString dataUsingEncoding:NSUTF8StringEncoding];
|
|
243
|
+
// NSError *jsonError;
|
|
244
|
+
// NSDictionary *responseDict = [NSJSONSerialization JSONObjectWithData:jsonData options:0 error:&jsonError];
|
|
245
|
+
//
|
|
246
|
+
// if (jsonError) {
|
|
247
|
+
// NSLog(@"Failed to parse JSON: %@", jsonError.localizedDescription);
|
|
248
|
+
// [self sendEventWithName:@"observeTransmitterUnbindStatusHandler" body:@{
|
|
249
|
+
// @"token": token ?: @"",
|
|
250
|
+
// @"success": @NO,
|
|
251
|
+
// @"error": @"Invalid JSON response from JS"
|
|
252
|
+
// }];
|
|
253
|
+
// return;
|
|
254
|
+
// }
|
|
255
|
+
//
|
|
256
|
+
// // Now you have responseDict, you can use it
|
|
257
|
+
// [self observeTransmitterUnbindStatusInternal:token response:responseDict completion:^(NSDictionary *response, NSError *error) {
|
|
258
|
+
// if (error) {
|
|
259
|
+
// NSDictionary *errorPayload = @{
|
|
260
|
+
// @"token": token ?: @"",
|
|
261
|
+
// @"success": @NO,
|
|
262
|
+
// @"error": error.localizedDescription ?: @"Unknown error"
|
|
263
|
+
// };
|
|
264
|
+
// [self sendEventWithName:@"observeTransmitterUnbindStatusHandler" body:errorPayload];
|
|
265
|
+
// } else {
|
|
266
|
+
// NSDictionary *successPayload = @{
|
|
267
|
+
// @"token": token ?: @"",
|
|
268
|
+
// @"responseFromBackend": response ?: @{},
|
|
269
|
+
// @"responseFromJS": responseDict ?: @{},
|
|
270
|
+
// @"success": @YES
|
|
271
|
+
// };
|
|
272
|
+
// [self sendEventWithName:@"observeTransmitterUnbindStatusHandler" body:successPayload];
|
|
273
|
+
// }
|
|
274
|
+
// }];
|
|
275
|
+
//
|
|
276
|
+
//}
|
|
277
|
+
|
|
294
278
|
@end
|
package/ios/Support/API.swift
CHANGED
package/ios/Support/Global.swift
CHANGED
|
@@ -15,7 +15,8 @@ enum Enum_stroyboard: String {
|
|
|
15
15
|
}
|
|
16
16
|
|
|
17
17
|
var watchCGMVideo = "https://www.youtube.com/embed/r5Zemc4R044?si=RPvayD39VzsZuXsA"
|
|
18
|
-
var applyingTheSensor = "https://www.youtube.com/embed/
|
|
18
|
+
var applyingTheSensor = "https://www.youtube.com/embed/O01BBxzxGmE?si=SblmJ14boqu7Y4qM"
|
|
19
|
+
var applyingTheTransmitter = "https://www.youtube.com/embed/6m3pxl5BK9A?si=08OGnUJf2BdvAYfd"
|
|
19
20
|
var connectionJourneyError = "https://www.youtube.com/embed/mVMBdUeTlhc?si=ODZSiDW96UqyFiZb"
|
|
20
21
|
var qrScanFailed = "https://www.youtube.com/embed/zRlFFdr-QD4?si=hjq4fQDysfkTOPLh"
|
|
21
22
|
|
|
@@ -20,15 +20,10 @@ class VideoTVC: UITableViewCell {
|
|
|
20
20
|
// Initialization code
|
|
21
21
|
imageViewPlay.loadGif(named: "play")
|
|
22
22
|
imageViewBackground.contentMode = .scaleAspectFill
|
|
23
|
-
|
|
24
|
-
let tapGesture = UITapGestureRecognizer(target: self, action: #selector(playButtonTapped))
|
|
25
|
-
imageViewPlay.addGestureRecognizer(tapGesture)
|
|
26
|
-
|
|
23
|
+
buttonPlay.addTarget(self, action: #selector(playButtonTapped), for: .touchUpInside)
|
|
27
24
|
}
|
|
28
25
|
|
|
29
26
|
@objc func playButtonTapped() {
|
|
30
27
|
onPlayVideo?()
|
|
31
28
|
}
|
|
32
|
-
|
|
33
|
-
|
|
34
29
|
}
|
|
@@ -125,7 +125,7 @@ extension AttachTransmitterViewController: UITableViewDelegate, UITableViewDataS
|
|
|
125
125
|
cell.onPlayVideo = {
|
|
126
126
|
let webVC = WebViewController()
|
|
127
127
|
webVC.modalPresentationStyle = .formSheet
|
|
128
|
-
webVC.videoURL = URL(string:
|
|
128
|
+
webVC.videoURL = URL(string: applyingTheTransmitter)
|
|
129
129
|
self.present(webVC, animated: true, completion: nil)
|
|
130
130
|
}
|
|
131
131
|
return cell
|
|
@@ -85,9 +85,17 @@ class ConnectToSensorViewController: UIViewController {
|
|
|
85
85
|
if screenType == .error {
|
|
86
86
|
bottomButton.hideRightArrow()
|
|
87
87
|
}
|
|
88
|
+
|
|
88
89
|
bottomButton.buttonTapCallback = {
|
|
89
|
-
let
|
|
90
|
-
|
|
90
|
+
let isForReconnect = UserDefaults.standard.bool(forKey: "isForReconnect")
|
|
91
|
+
if isForReconnect{
|
|
92
|
+
let vc = AttachTransmitterViewController.instantiate(fromStoryboard: Enum_stroyboard.Main.rawValue)
|
|
93
|
+
self.navigationController?.pushViewController(vc, animated: false)
|
|
94
|
+
} else {
|
|
95
|
+
let vc = PutOnTheSensorViewController.instantiate(fromStoryboard: Enum_stroyboard.Main.rawValue)
|
|
96
|
+
self.navigationController?.pushViewController(vc, animated: false)
|
|
97
|
+
}
|
|
98
|
+
|
|
91
99
|
}
|
|
92
100
|
|
|
93
101
|
customTopView.onDemoTapped = {
|
|
@@ -7,6 +7,8 @@
|
|
|
7
7
|
|
|
8
8
|
import UIKit
|
|
9
9
|
import WebKit
|
|
10
|
+
import CoreBluetooth
|
|
11
|
+
import CoreLocation
|
|
10
12
|
|
|
11
13
|
class StartConnectionViewController: UIViewController {
|
|
12
14
|
|
|
@@ -15,7 +17,13 @@ class StartConnectionViewController: UIViewController {
|
|
|
15
17
|
@IBOutlet weak var startConnectionJourneyButton: CustomOverlayButton!
|
|
16
18
|
@objc var isForReconnect: Bool = false
|
|
17
19
|
var webView: WKWebView!
|
|
18
|
-
|
|
20
|
+
// Declare the CBCentralManager
|
|
21
|
+
var centralManager: CBCentralManager?
|
|
22
|
+
var isBluetoothEnabled: Bool = false
|
|
23
|
+
|
|
24
|
+
// Declare the CLLocationManager
|
|
25
|
+
var locationManager: CLLocationManager?
|
|
26
|
+
var isLocationEnabled: Bool = false
|
|
19
27
|
|
|
20
28
|
enum enumTableRow: Int, CaseIterable {
|
|
21
29
|
case separator
|
|
@@ -40,11 +48,24 @@ class StartConnectionViewController: UIViewController {
|
|
|
40
48
|
ImageTVC.self,
|
|
41
49
|
ChargingIndicatorTVC.self])
|
|
42
50
|
tableView.reloadData()
|
|
43
|
-
|
|
51
|
+
UserDefaults.standard.set(isLocationEnabled, forKey: "isForReconnect")
|
|
52
|
+
|
|
53
|
+
let isForReconnect = UserDefaults.standard.bool(forKey: "isForReconnect")
|
|
54
|
+
if isForReconnect{
|
|
55
|
+
checkLocationPermission()
|
|
56
|
+
centralManager = CBCentralManager(delegate: self, queue: nil)
|
|
57
|
+
// If the switch is turned on, check if Bluetooth is powered on
|
|
58
|
+
checkBluetoothPermission()
|
|
59
|
+
}
|
|
44
60
|
startConnectionJourneyButton.labelText = "Start Connection Journey"
|
|
45
61
|
startConnectionJourneyButton.buttonTapCallback = {
|
|
46
|
-
|
|
47
|
-
|
|
62
|
+
|
|
63
|
+
if isForReconnect{
|
|
64
|
+
self.updateBottomButtonState()
|
|
65
|
+
} else {
|
|
66
|
+
let vc = ProvidePermissionViewController.instantiate(fromStoryboard: Enum_stroyboard.Main.rawValue)
|
|
67
|
+
self.navigationController?.pushViewController(vc, animated: false)
|
|
68
|
+
}
|
|
48
69
|
}
|
|
49
70
|
|
|
50
71
|
customTopView.onDemoTapped = {
|
|
@@ -66,6 +87,61 @@ class StartConnectionViewController: UIViewController {
|
|
|
66
87
|
self.navigationController?.pushViewController(vc, animated: false)
|
|
67
88
|
}
|
|
68
89
|
}
|
|
90
|
+
|
|
91
|
+
private func updateBottomButtonState() {
|
|
92
|
+
if isBluetoothEnabled && isLocationEnabled {
|
|
93
|
+
let vc = ConnectToTransmitterViewController.instantiate(fromStoryboard: Enum_stroyboard.Main.rawValue)
|
|
94
|
+
self.navigationController?.pushViewController(vc, animated: false)
|
|
95
|
+
} else {
|
|
96
|
+
let vc = ProvidePermissionViewController.instantiate(fromStoryboard: Enum_stroyboard.Main.rawValue)
|
|
97
|
+
self.navigationController?.pushViewController(vc, animated: false)
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
private func checkBluetoothPermission() {
|
|
102
|
+
isBluetoothEnabled = false
|
|
103
|
+
switch centralManager?.state {
|
|
104
|
+
case .unknown:
|
|
105
|
+
print("Bluetooth state is unknown.")
|
|
106
|
+
case .resetting:
|
|
107
|
+
print("Bluetooth state is resetting.")
|
|
108
|
+
case .unsupported:
|
|
109
|
+
print("Bluetooth is unsupported on this device.")
|
|
110
|
+
case .unauthorized:
|
|
111
|
+
print("Bluetooth is unauthorized.")
|
|
112
|
+
|
|
113
|
+
case .poweredOff:
|
|
114
|
+
print("Bluetooth is powered off.")
|
|
115
|
+
case .poweredOn:
|
|
116
|
+
print("Bluetooth is powered on and available.")
|
|
117
|
+
isBluetoothEnabled = true
|
|
118
|
+
case .none:
|
|
119
|
+
print("Unknown Bluetooth state.")
|
|
120
|
+
@unknown default:
|
|
121
|
+
print("Unknown Bluetooth state.")
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
// Function to check Location Permission and State
|
|
126
|
+
private func checkLocationPermission() {
|
|
127
|
+
// Check if location services are enabled
|
|
128
|
+
|
|
129
|
+
let status = CLLocationManager.authorizationStatus()
|
|
130
|
+
|
|
131
|
+
switch status {
|
|
132
|
+
case .notDetermined:
|
|
133
|
+
print("Location permission is not determined.")
|
|
134
|
+
// Request permission to use location services
|
|
135
|
+
locationManager?.requestWhenInUseAuthorization()
|
|
136
|
+
case .restricted, .denied:
|
|
137
|
+
print("Location permission is restricted or denied.")
|
|
138
|
+
case .authorizedWhenInUse, .authorizedAlways:
|
|
139
|
+
print("Location is authorized.")
|
|
140
|
+
isLocationEnabled = true
|
|
141
|
+
@unknown default:
|
|
142
|
+
print("Unknown location status.")
|
|
143
|
+
}
|
|
144
|
+
}
|
|
69
145
|
|
|
70
146
|
func checkForDevice() {
|
|
71
147
|
let manager = KLTBluetoothManager.shared()
|
|
@@ -127,3 +203,11 @@ extension StartConnectionViewController: UITableViewDelegate, UITableViewDataSou
|
|
|
127
203
|
}
|
|
128
204
|
}
|
|
129
205
|
}
|
|
206
|
+
|
|
207
|
+
|
|
208
|
+
extension StartConnectionViewController: CBCentralManagerDelegate, CLLocationManagerDelegate {
|
|
209
|
+
// Delegate method called when Bluetooth state changes
|
|
210
|
+
func centralManagerDidUpdateState(_ central: CBCentralManager) {
|
|
211
|
+
checkBluetoothPermission()
|
|
212
|
+
}
|
|
213
|
+
}
|