react-native-mytatva-rn-sdk 1.2.6 → 1.2.7

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.
@@ -13,7 +13,10 @@
13
13
 
14
14
  #import <Foundation/Foundation.h>
15
15
  #import <React/RCTBridgeModule.h>
16
+ #import <React/RCTEventEmitter.h>
16
17
 
17
- @interface MyReactNativeBridge : NSObject <RCTBridgeModule>
18
+ @interface MyReactNativeBridge : RCTEventEmitter <RCTBridgeModule>
18
19
 
19
20
  @end
21
+ @interface EventEmitterManager : RCTEventEmitter <RCTBridgeModule>
22
+ @end
@@ -8,6 +8,26 @@
8
8
  #import <Foundation/Foundation.h>
9
9
  #import "MyReactNativeBridge.h"
10
10
  #import <UIKit/UIKit.h>
11
+ #import <React/RCTEventDispatcher.h>
12
+ #import <React/RCTEventEmitter.h>
13
+
14
+ @implementation EventEmitterManager
15
+
16
+ RCT_EXPORT_MODULE();
17
+
18
+ // Define the supported events
19
+ - (NSArray<NSString *> *)supportedEvents {
20
+ return @[@"cgmDeviceEvent"]; // Event names to listen to in JS
21
+ }
22
+
23
+ // Example method to emit an event from native to JS
24
+ RCT_EXPORT_METHOD(emitEvent:(NSString *)message) {
25
+ // Send an event with the name "EventName" and a message payload
26
+ [self sendEventWithName:@"cgmDeviceEvent" body:@{@"status": message}];
27
+ }
28
+
29
+ @end
30
+
11
31
 
12
32
  @implementation MyReactNativeBridge
13
33
 
@@ -15,6 +35,43 @@
15
35
 
16
36
  RCT_EXPORT_MODULE();
17
37
 
38
+ // This method returns the list of events the module supports
39
+ - (NSArray<NSString *> *)supportedEvents
40
+ {
41
+ return @[@"cgmDeviceEvent"];
42
+ }
43
+
44
+ // Start listening for notifications
45
+ - (instancetype)init
46
+ {
47
+ if (self = [super init]) {
48
+ // Add observer for the notification from UIViewController
49
+ [[NSNotificationCenter defaultCenter] addObserver:self
50
+ selector:@selector(handleNotification:)
51
+ name:@"cgmDeviceEvent"
52
+ object:nil];
53
+ }
54
+ return self;
55
+ }
56
+
57
+
58
+ // Handle the incoming notification and emit the event to React Native
59
+ - (void)handleNotification:(NSNotification *)notification
60
+ {
61
+ // Extract data from the notification
62
+ NSDictionary *userInfo = notification.userInfo;
63
+
64
+ // Send the data to React Native via event emitter
65
+ [self sendEventWithName:@"cgmDeviceEvent" body:@{@"status": @"WARM_PERIOD_STARTED"}];
66
+ }
67
+
68
+ // Clean up the observer when the module is deallocated
69
+ - (void)dealloc
70
+ {
71
+ [[NSNotificationCenter defaultCenter] removeObserver:self];
72
+ }
73
+
74
+
18
75
  RCT_EXPORT_METHOD(startCgmTracky:(NSString *)token)
19
76
  {
20
77
  [[NSUserDefaults standardUserDefaults] setObject:token forKey:@"authToken"];
@@ -58,7 +58,9 @@ class AttachTransmitterViewController: UIViewController {
58
58
  self.viewModel.uploadData(data: arrayFromInitial)
59
59
  }
60
60
 
61
-
61
+ NotificationCenter.default.post(name: Notification.Name("cgmDeviceEvent"), object: nil, userInfo: ["a":"a"])
62
+ self.navigationController?.presentingViewController?.dismiss(animated: true, completion: nil)
63
+
62
64
  //let vc = ConnectToTransmitterViewController.instantiate(fromStoryboard: Enum_stroyboard.Main.rawValue)
63
65
  //self.navigationController?.pushViewController(vc, animated: true)
64
66
  }
@@ -93,7 +93,8 @@ class ConnectToTransmitterViewController: UIViewController, KLTBluetoothDelegate
93
93
  }
94
94
  bottomButton.buttonTapCallback = {
95
95
  if self.isForReconnect {
96
- self.dismiss(animated:true)
96
+ NotificationCenter.default.post(name: Notification.Name("cgmDeviceEvent"), object: nil, userInfo: ["a":"a"])
97
+ self.navigationController?.presentingViewController?.dismiss(animated: true, completion: nil)
97
98
  } else {
98
99
 
99
100
  let vc = ConnectToSensorViewController.instantiate(fromStoryboard: Enum_stroyboard.Main.rawValue)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-mytatva-rn-sdk",
3
- "version": "1.2.6",
3
+ "version": "1.2.7",
4
4
  "description": "a package to inject data into visit health pwa",
5
5
  "main": "lib/commonjs/index",
6
6
  "module": "lib/module/index",