react-native-visit-rn-sdk 6.0.3 → 6.0.4

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,14 +1,33 @@
1
1
  # react-native-visit-rn-sdk
2
2
 
3
- a package to inject data into visit health pwa
3
+ React Native SDK for displaying the Visit Health PWA and exchanging events
4
+ between the PWA and its host app.
4
5
 
5
6
  ## Installation
6
7
 
7
8
  ```sh
8
- npm install react-native-visit-rn-sdk @twilio/video-react-native-sdk@3.5.0 react-native-permissions@4.1.5 --legacy-peer-deps
9
+ npm install react-native-visit-rn-sdk@6.0.4 @twilio/video-react-native-sdk@3.5.0 react-native-permissions@4.1.5 react-native-webview@^13.16.0
9
10
  ```
10
11
 
11
- The minimum supported iOS deployment target is `12.4`.
12
+ `@twilio/video-react-native-sdk`, `react-native-permissions`, and
13
+ `react-native-webview` are required peer dependencies; they are not bundled
14
+ in the SDK. Install them in the host app as shown above.
15
+
16
+ The Twilio `3.5.0` peer metadata requires React `^19.1.0` and React Native
17
+ `^0.81.0`. If an existing project has npm peer-resolution errors, first verify
18
+ that its React and React Native versions are compatible. Use
19
+ `--legacy-peer-deps` only when the project's dependency policy intentionally
20
+ allows npm to skip peer-dependency enforcement; the flag does not make
21
+ incompatible native versions compatible.
22
+
23
+ SDK `6.0.4` requires Node.js `16` or newer, Android API `21` or newer, and an
24
+ iOS deployment target of `12.4` or newer. React Native and other native
25
+ dependencies may impose higher platform minimums. After installing or changing
26
+ iOS native dependencies, run:
27
+
28
+ ```sh
29
+ npx pod-install
30
+ ```
12
31
 
13
32
  ## Usage
14
33
 
@@ -22,7 +41,7 @@ import VisitRnSdkView, {
22
41
  const sdkRef = useRef<VisitRnSdkViewHandle>(null);
23
42
 
24
43
  const props: VisitRnSdkViewProps = {
25
- ssoLink: 'pre-generated-sso-link',
44
+ ssoLink: '<pre-generated SSO link>',
26
45
  // isLoggingEnabled is optional (boolean); defaults to false
27
46
  onEvent: (eventName, properties) => {
28
47
  if (eventName === 'INITIATE_PAYMENT') {
@@ -39,43 +58,105 @@ sdkRef.current?.sendEvent('PAYMENT_STATUS', { status: 'success' });
39
58
 
40
59
  `isLoggingEnabled` is optional. When omitted it defaults to `false`; if you pass it, the value must be a `boolean`.
41
60
 
42
- `VisitRnSdkViewProps` and `VisitRnSdkViewHandle` are exported for host apps that want to type wrappers or prop maps.
61
+ Provide a non-empty, pre-generated URL in `ssoLink`. Although the prop is
62
+ optional at the type level, an omitted or blank value causes the SDK to render
63
+ no WebView.
43
64
 
44
- ### Host ↔ Visit PWA events
65
+ `VisitRnSdkViewProps`, `VisitRnSdkViewHandle`, and `VisitEventProperties` are
66
+ exported for host apps that want to type wrappers, refs, callbacks, or event
67
+ payloads.
45
68
 
46
- Keep `VisitRnSdkView` mounted while the host payment UI is open.
69
+ ### Host ↔ Visit PWA events (6.0.4)
47
70
 
48
- - **PWA → host:** the PWA posts a WebView message with method `sendEventToHost` which is forwarded to `onEvent`.
71
+ The event bridge works the same way on Android and iOS. Keep
72
+ `VisitRnSdkView` mounted while the React Native client app displays any
73
+ external host UI so the SDK ref remains available.
74
+
75
+ #### Visit PWA / SDK → React Native client app
76
+
77
+ The Visit PWA sends a JSON message through the React Native WebView. Use
78
+ `sendEventToHost` as the method and provide a non-empty `eventName`:
49
79
 
50
80
  ```js
51
- window.ReactNativeWebView.postMessage(JSON.stringify({
52
- method: 'sendEventToHost',
53
- eventName: 'INITIATE_PAYMENT',
54
- ...otherParams
55
- }));
81
+ window.ReactNativeWebView.postMessage(
82
+ JSON.stringify({
83
+ method: 'sendEventToHost',
84
+ eventName: 'INITIATE_PAYMENT',
85
+ orderId: '<order-id>',
86
+ })
87
+ );
88
+ ```
89
+
90
+ The SDK removes `method` and `eventName` from the message and passes every
91
+ remaining top-level field to the client app as `properties`. Receive the event
92
+ through the optional `onEvent` callback:
93
+
94
+ ```tsx
95
+ import { useRef } from 'react';
96
+ import VisitRnSdkView, {
97
+ type VisitRnSdkViewHandle,
98
+ } from 'react-native-visit-rn-sdk';
99
+
100
+ const sdkRef = useRef<VisitRnSdkViewHandle>(null);
101
+
102
+ <VisitRnSdkView
103
+ ref={sdkRef}
104
+ ssoLink="<pre-generated SSO link>"
105
+ onEvent={(eventName, properties) => {
106
+ if (eventName === 'INITIATE_PAYMENT') {
107
+ // Open the client app's payment UI.
108
+ // Read the example order ID from properties?.orderId.
109
+ }
110
+ }}
111
+ />;
56
112
  ```
57
113
 
58
- - **Host → PWA:** call `sendEvent` on the SDK ref. The Visit PWA must implement:
114
+ #### React Native client app → Visit PWA / SDK
115
+
116
+ Call `sendEvent(eventName, properties)` on the SDK ref to send an event back
117
+ into the Visit PWA. For example, after the client app finishes the payment
118
+ flow:
119
+
120
+ ```tsx
121
+ sdkRef.current?.sendEvent('PAYMENT_STATUS', {
122
+ status: 'success',
123
+ });
124
+ ```
125
+
126
+ The SDK invokes `window.sendEventToVisit(eventName, properties)` inside the
127
+ Visit PWA. The Visit PWA must define that function:
59
128
 
60
129
  ```js
61
130
  window.sendEventToVisit = function (eventName, properties) {
62
- // TODO
131
+ if (eventName === 'PAYMENT_STATUS') {
132
+ // Continue the Visit flow using properties.status.
133
+ }
63
134
  };
64
135
  ```
65
136
 
137
+ - `properties` is optional. When omitted, the SDK passes an empty object (`{}`).
138
+ - `eventName` must be a non-empty string. `sendEvent` also rejects names that
139
+ contain only whitespace. Messages without a valid event name are ignored.
140
+ - Built-in WebView bridge messages are handled internally. Only messages using
141
+ `method: 'sendEventToHost'` are delivered through `onEvent`.
142
+ - Keep `VisitRnSdkView` mounted while external client-app UI is open so
143
+ `sdkRef.current` remains available.
144
+
66
145
  ## Location permissions
67
146
 
68
- Android host apps must declare both foreground location permissions:
147
+ Android host apps that use Visit's location flow must declare both foreground
148
+ location permissions:
69
149
 
70
150
  ```xml
71
151
  <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
72
152
  <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
73
153
  ```
74
154
 
75
- When the web application sends `GET_LOCATION_PERMISSIONS`, the SDK checks for
76
- fine-location access. It requests fine location through the normal Android
155
+ When the web application sends `GET_LOCATION_PERMISSIONS`, the Android SDK
156
+ checks for fine-location access. It requests fine location through the normal
77
157
  runtime permission dialog when possible. If permission is blocked, the SDK
78
- offers to open the app's settings page.
158
+ offers to open the app's settings page. Runtime permission handling uses the
159
+ required `react-native-permissions` peer dependency.
79
160
 
80
161
  After permission is granted, the SDK checks the phone's Location Services
81
162
  setting. It never displays an in-app GPS enable prompt; instead, it offers to
@@ -87,8 +168,11 @@ window.checkTheGpsPermission(true); // Fine location and Location Services enabl
87
168
  window.checkTheGpsPermission(false); // Either requirement is unavailable
88
169
  ```
89
170
 
90
- Approximate/coarse-only location access is not sufficient. The iOS behavior is
91
- unchanged and continues to report `true` for `GET_LOCATION_PERMISSIONS`.
171
+ Approximate/coarse-only location access is not sufficient. On iOS,
172
+ `GET_LOCATION_PERMISSIONS` currently calls
173
+ `window.checkTheGpsPermission(true)` without requesting or checking an iOS
174
+ location permission. Do not treat that callback as proof that the host app has
175
+ iOS location authorization.
92
176
 
93
177
  ## Dependency and event migration
94
178
 
@@ -103,10 +187,10 @@ global event emitter, and the example app's unused
103
187
  `unauthorized-wellness-access` listener has been removed. WebView errors are
104
188
  logged only when `isLoggingEnabled={true}`.
105
189
 
106
- ## Migrating to 6.0.1
190
+ ## Migrating from versions before 6.0.1
107
191
 
108
- Pass the pre-generated SSO URL through `ssoLink`. This is the only URL prop in
109
- `6.0.1`; `isLoggingEnabled` remains optional and defaults to `false`.
192
+ Pass the pre-generated SSO URL through `ssoLink`. This is the only URL prop;
193
+ `isLoggingEnabled` remains optional and defaults to `false`.
110
194
 
111
195
  ## Migrating to 6.0.0
112
196
 
@@ -115,22 +199,21 @@ Host apps no longer need to add HealthKit entitlements, HealthKit usage
115
199
  descriptions, Health Connect permissions, or Health Connect rationale screens
116
200
  for this package.
117
201
 
118
- `VisitRnSdkView` accepts only a pre-generated `ssoLink` plus the optional
119
- `isLoggingEnabled` flag. The SDK no longer accepts `cpsid`, `baseUrl`,
120
- `errorBaseUrl`, `token`, `moduleName`, or `environment`, and it no longer
121
- generates magic links internally.
202
+ The SDK no longer accepts `cpsid`, `baseUrl`, `errorBaseUrl`, `token`,
203
+ `moduleName`, or `environment`, and it no longer generates magic links
204
+ internally. The current `6.0.4` component props are `ssoLink`,
205
+ `isLoggingEnabled`, and `onEvent`; its ref exposes `sendEvent`.
122
206
 
123
- ### Video Calling
207
+ ## Video calling
124
208
 
125
- `react-native-visit-rn-sdk` declares [`@twilio/video-react-native-sdk`](https://www.npmjs.com/package/@twilio/video-react-native-sdk) as a **peer dependency**. Install the matching version in your app:
209
+ `react-native-visit-rn-sdk@6.0.4` declares
210
+ [`@twilio/video-react-native-sdk`](https://www.npmjs.com/package/@twilio/video-react-native-sdk)
211
+ `3.5.0` as an exact peer dependency. Install it with the SDK as shown in the
212
+ [Installation](#installation) section.
126
213
 
127
- ```sh
128
- npm install @twilio/video-react-native-sdk@3.5.0 --legacy-peer-deps
129
- ```
130
-
131
- Required native permissions in the host app:
132
-
133
- - Android (`AndroidManifest.xml`)
214
+ Twilio's Android library declares its camera and audio permissions in its own
215
+ manifest, so Android's manifest merger normally adds them to the host app.
216
+ Verify that the merged release manifest contains:
134
217
 
135
218
  ```xml
136
219
  <uses-permission android:name="android.permission.CAMERA" />
@@ -138,7 +221,8 @@ Required native permissions in the host app:
138
221
  <uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
139
222
  ```
140
223
 
141
- - iOS (`Info.plist`)
224
+ The iOS host app must provide camera and microphone usage descriptions in
225
+ `Info.plist`:
142
226
 
143
227
  ```xml
144
228
  <key>NSCameraUsageDescription</key>
@@ -147,19 +231,10 @@ Required native permissions in the host app:
147
231
  <string>Visit needs microphone access for video consultations.</string>
148
232
  ```
149
233
 
150
- Proguard Rules (Android)
151
-
152
- ```pro
153
- # Twilio Video SDK
154
- -keep class com.twilio.** { *; }
155
-
156
- # Twilio-packaged WebRTC classes
157
- -keep class tvi.webrtc.** { *; }
158
-
159
- # Optional: reduce warning noise
160
- -dontwarn tvi.webrtc.**
161
- -dontwarn com.twilio.**
162
- ```
234
+ Twilio `3.5.0` does not prescribe extra app-level ProGuard/R8 rules in its
235
+ published React Native setup. If a minified release reports shrinker errors,
236
+ resolve those specific diagnostics for the dependency versions in that app
237
+ instead of applying blanket keep and `-dontwarn` rules.
163
238
 
164
239
  ## Contributing
165
240
 
@@ -155,7 +155,7 @@ const VisitRnSdkView = /*#__PURE__*/(0, _react.forwardRef)(function VisitRnSdkVi
155
155
  const runBeforeFirst = `
156
156
  window.isNativeApp = true;
157
157
  window.platform = "ANDROID";
158
- window.setSdkPlatform('ANDROID');
158
+ window.setSdkPlatform?.('ANDROID');
159
159
  true; // note: this is required, or you'll sometimes get silent failures
160
160
  `;
161
161
  const sendEvent = (0, _react.useCallback)((eventName, properties) => {
@@ -45,7 +45,7 @@ const VisitRnSdkView = /*#__PURE__*/(0, _react.forwardRef)(function VisitRnSdkVi
45
45
  const runBeforeFirst = `
46
46
  window.isNativeApp = true;
47
47
  window.platform = "IOS";
48
- window.setSdkPlatform('IOS');
48
+ window.setSdkPlatform?.('IOS');
49
49
  true; // note: this is required, or you'll sometimes get silent failures
50
50
  `;
51
51
  const sendEvent = (0, _react.useCallback)((eventName, properties) => {
@@ -147,7 +147,7 @@ const VisitRnSdkView = /*#__PURE__*/forwardRef(function VisitRnSdkView({
147
147
  const runBeforeFirst = `
148
148
  window.isNativeApp = true;
149
149
  window.platform = "ANDROID";
150
- window.setSdkPlatform('ANDROID');
150
+ window.setSdkPlatform?.('ANDROID');
151
151
  true; // note: this is required, or you'll sometimes get silent failures
152
152
  `;
153
153
  const sendEvent = useCallback((eventName, properties) => {
@@ -37,7 +37,7 @@ const VisitRnSdkView = /*#__PURE__*/forwardRef(function VisitRnSdkView({
37
37
  const runBeforeFirst = `
38
38
  window.isNativeApp = true;
39
39
  window.platform = "IOS";
40
- window.setSdkPlatform('IOS');
40
+ window.setSdkPlatform?.('IOS');
41
41
  true; // note: this is required, or you'll sometimes get silent failures
42
42
  `;
43
43
  const sendEvent = useCallback((eventName, properties) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-visit-rn-sdk",
3
- "version": "6.0.3",
3
+ "version": "6.0.4",
4
4
  "description": "a package to inject data into visit health pwa",
5
5
  "main": "lib/commonjs/index",
6
6
  "module": "lib/module/index",
@@ -85,6 +85,7 @@
85
85
  "react-native": "0.72.4",
86
86
  "react-native-builder-bob": "^0.20.0",
87
87
  "react-native-permissions": "4.1.5",
88
+ "react-native-webview": "^13.12.1",
88
89
  "react-test-renderer": "18.2.0",
89
90
  "release-it": "^15.0.0",
90
91
  "turbo": "^1.10.7",
@@ -94,7 +95,8 @@
94
95
  "@twilio/video-react-native-sdk": "3.5.0",
95
96
  "react": "*",
96
97
  "react-native": "*",
97
- "react-native-permissions": "^4.1.5"
98
+ "react-native-permissions": "^4.1.5",
99
+ "react-native-webview": "*"
98
100
  },
99
101
  "engines": {
100
102
  "node": ">= 16.0.0"
@@ -176,9 +178,6 @@
176
178
  ]
177
179
  ]
178
180
  },
179
- "dependencies": {
180
- "react-native-webview": "^13.12.1"
181
- },
182
181
  "directories": {
183
182
  "example": "example"
184
183
  }
@@ -257,7 +257,7 @@ const VisitRnSdkView = forwardRef<VisitRnSdkViewHandle, VisitRnSdkViewProps>(
257
257
  const runBeforeFirst = `
258
258
  window.isNativeApp = true;
259
259
  window.platform = "ANDROID";
260
- window.setSdkPlatform('ANDROID');
260
+ window.setSdkPlatform?.('ANDROID');
261
261
  true; // note: this is required, or you'll sometimes get silent failures
262
262
  `;
263
263
 
package/src/index.ios.tsx CHANGED
@@ -70,7 +70,7 @@ const VisitRnSdkView = forwardRef<VisitRnSdkViewHandle, VisitRnSdkViewProps>(
70
70
  const runBeforeFirst = `
71
71
  window.isNativeApp = true;
72
72
  window.platform = "IOS";
73
- window.setSdkPlatform('IOS');
73
+ window.setSdkPlatform?.('IOS');
74
74
  true; // note: this is required, or you'll sometimes get silent failures
75
75
  `;
76
76