react-native-visit-rn-sdk 3.0.9 → 3.0.11

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/README.md CHANGED
@@ -1,7 +1,7 @@
1
1
  ### **Instructions for configuring your Android Project**
2
2
 
3
3
  * Install Visit React Native Plugin
4
- `npm install react-native-visit-rn-sdk@3.0.7`
4
+ `npm install react-native-visit-rn-sdk@3.0.11`
5
5
  * Install these transitive plugins that Visit Plugin requires internally:
6
6
  `npm install react-native-device-info`
7
7
  `npm install https://github.com/sashko9807/react-native-location-enabler`
@@ -42,7 +42,7 @@ android {
42
42
 
43
43
  ### **Instructions for configuring Plugin in iOS project**
44
44
 
45
- * Add the plugin `npm install react-native-visit-rn-sdk@3.0.7 && npx pod-install`
45
+ * Add the plugin `npm install react-native-visit-rn-sdk@3.0.11 && npx pod-install`
46
46
  * Install pods(for M1 processors running build on `x86_64` hardware)
47
47
 
48
48
  `arch -x86_64 pod install`
@@ -82,7 +82,148 @@ function App() {
82
82
  export default App;
83
83
  ```
84
84
 
85
- To see the full usage code for getting Health Connect/Health Kit connection status and retriving step data, refer [here](https://github.com/VisitApp/Visit-ReactNative/blob/master/example/App.js).
85
+ To see the full usage code for getting Health Connect/HealthKit connection status and retrieving health data, refer [here](https://github.com/VisitApp/Visit-ReactNative/blob/mchi-rn-sdk-3x/example/App.js).
86
+
87
+ ## **Health Connect Connection Flow (Android)**
88
+
89
+ Version `3.0.11` uses AndroidSDK `v3.13` and routes the PWA's Health Connect request according to the Health Connect installation status and the device's native step-tracking capability.
90
+
91
+ The maintained RN 3.x release is also available through its npm dist-tag:
92
+
93
+ ```bash
94
+ npm install react-native-visit-rn-sdk@rn3
95
+ ```
96
+
97
+ Native step tracking is available only when both of these requirements are met:
98
+
99
+ * Android 14/API 34 or later.
100
+ * SDK Extension version 20 or later.
101
+
102
+ When native step tracking is unavailable, the PWA should explain that the user needs a compatible third-party fitness tracker app to write step data to Health Connect. The educational modal is implemented by the PWA, not by the React Native SDK.
103
+
104
+ The following chart summarizes the four supported user journeys. The scenario numbers can also be used to identify the corresponding demonstration videos.
105
+
106
+ ```mermaid
107
+ flowchart TD
108
+ A["User taps Connect to Health Connect"] --> B{"Android version?"}
109
+
110
+ B -->|"Below Android 14"| C{"Is the Health Connect app installed?"}
111
+ C -->|"No"| S1["Scenario 1<br/>Open the Health Connect Play Store page"]
112
+ S1 --> R["User installs Health Connect and returns to the app"]
113
+ R --> A
114
+ C -->|"Yes"| S2["Scenario 2<br/>Show the third-party fitness tracker disclaimer"]
115
+
116
+ B -->|"Android 14 or later"| D{"Native step tracking available?<br/>API 34+ and SDK Extension 20+"}
117
+ D -->|"Yes"| S3["Scenario 3<br/>Start the Health Connect permission flow directly"]
118
+ D -->|"No"| S4["Scenario 4<br/>Show the third-party fitness tracker disclaimer"]
119
+
120
+ S2 --> T["User installs or connects a compatible tracker<br/>Google Fit, Fitbit, or Samsung Health"]
121
+ S4 --> T
122
+ T --> E["User selects Continue"]
123
+ E --> P["Start the Health Connect permission flow"]
124
+ ```
125
+
126
+ ### **Routing Behavior**
127
+
128
+ | Condition | SDK behavior | Show the PWA disclaimer |
129
+ | --- | --- | --- |
130
+ | `disclaimerAccepted === true` | Start the existing Health Connect permission flow immediately. | No |
131
+ | Health Connect status check fails | Report the error and start the existing permission flow. | No |
132
+ | Health Connect status is `NOT_INSTALLED` | Start the existing native flow, which opens the Health Connect Play Store page. | No |
133
+ | Health Connect is available and native step tracking is supported | Start the permission flow immediately. | No |
134
+ | Health Connect is available and native step tracking is unsupported | Invoke `window.showHealthConnectDisclaimer()`. | Yes |
135
+ | Native step capability check fails | Treat native step tracking as unavailable and invoke the disclaimer callback. | Yes |
136
+
137
+ Every `CONNECT_TO_GOOGLE_FIT` message is processed. There is no in-flight request guard, so after returning from the Play Store the PWA can send the message again to restart the flow.
138
+
139
+ ### **PWA Contract**
140
+
141
+ On the initial **Connect to Health Connect** action, send:
142
+
143
+ ```javascript
144
+ window.ReactNativeWebView.postMessage(
145
+ JSON.stringify({
146
+ method: 'CONNECT_TO_GOOGLE_FIT',
147
+ })
148
+ );
149
+ ```
150
+
151
+ When Health Connect is available but native step tracking is unavailable, the SDK invokes:
152
+
153
+ ```javascript
154
+ window.showHealthConnectDisclaimer();
155
+ ```
156
+
157
+ The PWA must define this function and use it to open the educational modal:
158
+
159
+ ```javascript
160
+ window.showHealthConnectDisclaimer = function () {
161
+ // Open the PWA-managed Health Connect disclaimer modal.
162
+ };
163
+ ```
164
+
165
+ After the user selects **Continue** in the modal, send the same method with a strict boolean acceptance flag:
166
+
167
+ ```javascript
168
+ window.ReactNativeWebView.postMessage(
169
+ JSON.stringify({
170
+ method: 'CONNECT_TO_GOOGLE_FIT',
171
+ disclaimerAccepted: true,
172
+ })
173
+ );
174
+ ```
175
+
176
+ Only the boolean value `true` bypasses the status and capability checks. A missing, `false`, string, or otherwise malformed value is handled as a new Connect request. Acceptance is not persisted by the SDK.
177
+
178
+ ### **Android Native Methods**
179
+
180
+ The routing flow uses these methods from `NativeModules.VisitFitnessModule`:
181
+
182
+ | Method | Result |
183
+ | --- | --- |
184
+ | `getHealthConnectStatus()` | Resolves with `NOT_SUPPORTED`, `NOT_INSTALLED`, `INSTALLED`, or `CONNECTED`. |
185
+ | `isNativeStepTrackingAvailable()` | Resolves with a boolean. Unexpected failures reject with `CAPABILITY_CHECK_FAILED`. |
186
+ | `askForFitnessPermission()` | Starts the install/permission flow and resolves with `GRANTED` or `CANCELLED` when the permission request completes. |
187
+
188
+ The capability method does not require a separate Activity reference at call time. Health Connect aggregation remains unchanged and does not filter by `DataOrigin`, so native phone steps are included when the platform provides them.
189
+
190
+ ### **Health Connect Logs**
191
+
192
+ Set `isLoggingEnabled={true}` on `VisitRnSdkView` to log the status, capability result, routing decision, and native check failures. Routing messages use this prefix:
193
+
194
+ ```text
195
+ [VisitRnSdk][HealthConnect]
196
+ ```
197
+
198
+ ## **RN 3.x Release Notes**
199
+
200
+ ### **3.0.11**
201
+
202
+ * Upgrade AndroidSDK to `v3.13`.
203
+ * Reconcile hourly step buckets with Health Connect's exact daily aggregate so the graph total matches the daily total despite hourly fractional-step truncation.
204
+ * Keep the existing React Native APIs and PWA callback signatures unchanged.
205
+
206
+ ### **3.0.10**
207
+
208
+ * Upgrade AndroidSDK to `v3.12`.
209
+ * Keep the existing React Native APIs and PWA callbacks unchanged while Android returns compatibility zero values for removed calorie, distance, and sleep Health Connect data.
210
+
211
+ ### **3.0.9**
212
+
213
+ * Check Health Connect installation status before native step capability.
214
+ * Route `NOT_INSTALLED` directly to the native install/permission flow instead of the PWA disclaimer.
215
+ * Route Health Connect status-check failures to the permission flow.
216
+ * Keep capability-check failures on the PWA disclaimer fallback.
217
+
218
+ ### **3.0.8**
219
+
220
+ * Remove duplicate-request suppression so the PWA can restart the flow after the user returns from the Health Connect Play Store page.
221
+
222
+ ### **3.0.7**
223
+
224
+ * Add Android native step-tracking capability detection through AndroidSDK `v3.11`.
225
+ * Add the `window.showHealthConnectDisclaimer()` PWA callback and strict `disclaimerAccepted: true` continuation contract.
226
+ * Add Health Connect routing logs for supported, unsupported, and failed capability checks.
86
227
 
87
228
  ### **Sample Project**
88
229
 
@@ -101,7 +101,7 @@ dependencies {
101
101
  //noinspection GradleDynamicVersion
102
102
  implementation "com.facebook.react:react-native:+"
103
103
  implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
104
- implementation "com.github.VisitApp:AndroidSDK:v3.11"
104
+ implementation "com.github.VisitApp:AndroidSDK:v3.13"
105
105
  implementation "androidx.health.connect:connect-client:1.1.0"
106
106
  implementation "com.jakewharton.timber:timber:5.0.1"
107
107
  implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:1.8.1"
@@ -4,8 +4,6 @@
4
4
 
5
5
  @interface VisitRnSdkViewManager : RCTEventEmitter <RCTBridgeModule>{
6
6
  NSCalendar* calendar;
7
- NSUInteger bmrCaloriesPerHour;
8
- NSString *gender;
9
7
  BOOL hasLoadedOnce;
10
8
  }
11
9
 
@@ -21,8 +19,6 @@
21
19
  - (void)getHealthKitStatus:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject;
22
20
  - (void)requestHealthKitAuthorization:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject;
23
21
  - (void)getTodayStepCount:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject;
24
- - (void)getTodaySleepMinutes:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject;
25
- - (void)getTodayCalorieCount:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject;
26
22
  - (void)triggerManualSync:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject;
27
23
 
28
24
  @end