zh-web-sdk 2.5.1 → 2.5.2
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 +31 -288
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,310 +1,53 @@
|
|
|
1
1
|
# ZeroHash Platform SDK
|
|
2
2
|
|
|
3
|
-
This SDK exposes functionality that allows platforms to integrate with ZeroHash on the web.
|
|
4
|
-
You should be able to access different UI flows, such as Onboarding and Crypto Withdrawals
|
|
5
|
-
using a single instance of `ZeroHashSDK`.
|
|
3
|
+
This SDK (Software development Kit) exposes functionality that allows platforms to integrate with ZeroHash on the web and mobile. You should be able to access different UI flows, such as Crypto Buy, Crypto Sell, Crypto Withdrawals, Fiat Deposits, Fiat Withdrawals and Onboarding using a single instance of ZeroHashSDK.
|
|
6
4
|
|
|
7
|
-
## Migrating from 1.x.x to 2.x.x
|
|
8
|
-
On SDK v2 we added some new methods that will replace the ones marked with deprecated
|
|
9
|
-
on future releases, if you update our SDK to v2 but don't do the below changes,
|
|
10
|
-
your App should still work fine as we ensured everything is backwards compatible, but
|
|
11
|
-
we recommend that when updating to v2 you follow the steps below to ensure your App
|
|
12
|
-
is kept up to date with our SDK.
|
|
13
|
-
### Instantiating the SDK
|
|
14
|
-
- `zeroHashOnboardingURL` was renamed to `zeroHashAppsURL`. Please replace `zeroHashOnboardingURL` with `zeroHashAppsURL`.
|
|
15
5
|
### SDK Methods
|
|
6
|
+
|
|
16
7
|
```javascript
|
|
17
8
|
import { AppIdentifier } from 'zh-web-sdk'
|
|
18
9
|
|
|
19
|
-
|
|
20
|
-
sdk.
|
|
21
|
-
sdk.openModal({appIdentifier: AppIdentifier.ONBOARDING, jwt: jwt}) // New method
|
|
22
|
-
sdk.openOnboardingModal({}) // Deprecated method
|
|
23
|
-
sdk.openModal({appIdentifier: AppIdentifier.ONBOARDING}) // New method
|
|
10
|
+
sdk.openModal({appIdentifier: AppIdentifier.ONBOARDING, jwt: jwt})
|
|
11
|
+
sdk.openModal({appIdentifier: AppIdentifier.ONBOARDING})
|
|
24
12
|
|
|
25
|
-
|
|
26
|
-
sdk.closeOnboardingModal() // Deprecated method
|
|
27
|
-
sdk.closeModal(AppIdentifier.ONBOARDING) // New method
|
|
13
|
+
sdk.closeModal(AppIdentifier.ONBOARDING)
|
|
28
14
|
|
|
29
|
-
|
|
30
|
-
sdk.setUserOnboardingJWT({ userOnboardingJWT: jwt }) // Deprecated method
|
|
31
|
-
sdk.setJWT({ jwt: jwt, appIdentifier: AppIdentifier.ONBOARDING }) // New method
|
|
15
|
+
sdk.setJWT({ jwt: jwt, appIdentifier: AppIdentifier.ONBOARDING })
|
|
32
16
|
|
|
33
|
-
|
|
34
|
-
sdk.isOnboardingModalOpen() // Deprecated method
|
|
35
|
-
sdk.isModalOpen(AppIdentifier.ONBOARDING) // New method
|
|
17
|
+
sdk.isModalOpen(AppIdentifier.ONBOARDING)
|
|
36
18
|
```
|
|
37
19
|
|
|
38
|
-
|
|
20
|
+
See the `ZeroHashSDK` class in `index.d.ts` in `/dist`.
|
|
39
21
|
|
|
40
|
-
|
|
22
|
+
## Quick Setup
|
|
23
|
+
|
|
24
|
+
```typescript
|
|
25
|
+
import React from 'react';
|
|
41
26
|
import ZeroHashSDK, { AppIdentifier } from 'zh-web-sdk';
|
|
42
27
|
|
|
43
|
-
|
|
44
|
-
const sdk = new ZeroHashSDK({
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
28
|
+
const App = () => {
|
|
29
|
+
const sdk = new ZeroHashSDK({
|
|
30
|
+
// For cert use "https://web-sdk.cert.zerohash.com"
|
|
31
|
+
zeroHashAppsURL: "https://web-sdk.zerohash.com",
|
|
32
|
+
// JWT can be set later, when opening the Modal using `openModal` method
|
|
33
|
+
cryptoBuyJWT: "<JWT_TOKEN_HERE>"
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
sdk.openModal({appIdentifier: AppIdentifier.CRYPTO_BUY})
|
|
37
|
+
return <></>;
|
|
38
|
+
}
|
|
48
39
|
|
|
49
|
-
|
|
50
|
-
// i.e. you should not use your Onboarding JWT for Crypto Witdhrawals)
|
|
51
|
-
// before the user can proceed with the flow.
|
|
52
|
-
sdk.openModal({
|
|
53
|
-
appIdentifier: AppIdentifier.ONBOARDING,
|
|
54
|
-
jwt: "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9." +
|
|
55
|
-
"eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ." +
|
|
56
|
-
"SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c"
|
|
57
|
-
});
|
|
40
|
+
export default App;
|
|
58
41
|
```
|
|
59
42
|
|
|
60
|
-
## API
|
|
61
|
-
|
|
62
|
-
See the `ZeroHashSDK` class in `index.d.ts` in `/dist`.
|
|
63
|
-
|
|
64
|
-
If you are browsing this repository, you can find the implementation in `index.tsx`.
|
|
65
|
-
|
|
66
43
|
## Versioning
|
|
67
44
|
|
|
68
|
-
The
|
|
69
|
-
|
|
70
|
-
- `BREAKING CHANGE` is a major release (`1.0.0` to `2.0.0`)
|
|
71
|
-
- `feat` is a minor release (`1.0.0` to `1.1.0`)
|
|
72
|
-
- default is a patch release (`1.0.0` to `1.0.1`)
|
|
45
|
+
The ZeroHash SDK uses [Semantic Versioning 2.0.0](https://semver.org/). Version numbers follow the `MAJOR.MINOR.PATCH` format:
|
|
73
46
|
|
|
74
|
-
|
|
75
|
-
|
|
47
|
+
- **MAJOR** version increments when we make incompatible API changes (e.g., `1.0.0` to `2.0.0`).
|
|
48
|
+
- **MINOR** version increments when we add new functionality in a backward-compatible manner (e.g., `1.0.0` to `1.1.0`).
|
|
49
|
+
- **PATCH** version increments when we make backward-compatible bug fixes (e.g., `1.0.0` to `1.0.1`).
|
|
76
50
|
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
These are the URLs your `WebView` should use on your Mobile App.
|
|
81
|
-
|
|
82
|
-
### React native guide
|
|
83
|
-
|
|
84
|
-
#### Events
|
|
85
|
-
We forward events that come from the UI to the Native App using the `postMessage` API. You can handle these events using `onMessage` from the `WebView` component. Currently these are the events we have, for the respective Apps:
|
|
86
|
-
- **Onboarding:**
|
|
87
|
-
- `ONBOARDING_APP_LOADED` Sent when the App is loaded in the first time
|
|
88
|
-
- `ONBOARDING_CLOSE_BUTTON_CLICKED` Sent when the user clicks the Close button on the top-right corner
|
|
89
|
-
- `ONBOARDING_PENDING_APPROVAL` Sent when flow is on pending approval state (e.g. document validation)
|
|
90
|
-
- `ONBOARDING_COMPLETED` Sent when user finished flow successfully with participant approved and webview can be closed
|
|
91
|
-
- `ONBOARDING_FAILED` Send when something went wrong in the flow (errored state)
|
|
92
|
-
- **Crypto Withdrawals:**
|
|
93
|
-
- `CRYPTO_WITHDRAWALS_APP_LOADED` Sent when the App is loaded in the first time
|
|
94
|
-
- `CRYPTO_WITHDRAWALS_CLOSE_BUTTON_CLICKED` Sent when the user clicks the Close button on the top-right corner
|
|
95
|
-
- `CRYPTO_WITHDRAWALS_COMPLETED` Sent when user finished flow successfully
|
|
96
|
-
- `CRYPTO_WITHDRAWALS_FAILED` Send when something went wrong in the flow (errored state)
|
|
97
|
-
- **Fiat Deposits:**
|
|
98
|
-
- `FIAT_DEPOSITS_APP_LOADED` Sent when the App is loaded in the first time
|
|
99
|
-
- `FIAT_DEPOSITS_CLOSE_BUTTON_CLICKED` Sent when the user clicks the Close button on the top-right corner
|
|
100
|
-
- `FIAT_DEPOSITS_COMPLETED` Sent when user finished flow successfully
|
|
101
|
-
- `FIAT_DEPOSITS_FAILED` Send when something went wrong in the flow (errored state)
|
|
102
|
-
- **Fiat Withdrawals:**
|
|
103
|
-
- `FIAT_WITHDRAWALS_APP_LOADED` Sent when the App is loaded in the first time
|
|
104
|
-
- `FIAT_WITHDRAWALS_CLOSE_BUTTON_CLICKED` Sent when the user clicks the Close button on the top-right corner
|
|
105
|
-
- `FIAT_WITHDRAWALS_COMPLETED` Sent when user finished flow successfully
|
|
106
|
-
- `FIAT_WITHDRAWALS_FAILED` Send when something went wrong in the flow (errored state)
|
|
107
|
-
- **Crypto Buy:**
|
|
108
|
-
- `CRYPTO_BUY_APP_LOADED` Sent when the App is loaded in the first time
|
|
109
|
-
- `CRYPTO_BUY_CLOSE_BUTTON_CLICKED` Sent when the user clicks the Close button on the top-right corner
|
|
110
|
-
- `CRYPTO_BUY_COMPLETED` Sent when user finished flow successfully
|
|
111
|
-
- `CRYPTO_BUY_FAILED` Send when something went wrong in the flow (errored state)
|
|
112
|
-
- **Crypto Sell:**
|
|
113
|
-
- `CRYPTO_SELL_APP_LOADED` Sent when the App is loaded in the first time
|
|
114
|
-
- `CRYPTO_SELL_CLOSE_BUTTON_CLICKED` Sent when the user clicks the Close button on the top-right corner
|
|
115
|
-
- `CRYPTO_SELL_COMPLETED` Sent when user finished flow successfully
|
|
116
|
-
- `CRYPTO_SELL_FAILED` Send when something went wrong in the flow (errored state)
|
|
117
|
-
|
|
118
|
-
#### Messages
|
|
119
|
-
To control the `WebView` you can also send messages *down*, using the `postMessage` API. Currently the accepted messages for the respective Apps are:
|
|
120
|
-
- **Onboarding**
|
|
121
|
-
- `{type: "OPEN_MODAL", payload:{jwt: "<JWT_HERE>", appIdentifier: "onboarding"} }`: It will open the onboarding modal with the JWT provided
|
|
122
|
-
- `{type: "CLOSE_MODAL", payload:{appIdentifier: "onboarding"}}`: It will close the onboarding modal
|
|
123
|
-
- **Crypto Withdrawals**
|
|
124
|
-
- `{type: "OPEN_MODAL", payload:{jwt: "<JWT_HERE>", appIdentifier: "crypto-withdrawals"} }`: It will open the Crypto Withdrawals modal with the JWT provided
|
|
125
|
-
- `{type: "CLOSE_MODAL", payload:{appIdentifier: "crypto-withdrawals"}}`: It will close the Crypto Withdrawals modal
|
|
126
|
-
- **Fiat Deposits**
|
|
127
|
-
- `{type: "OPEN_MODAL", payload:{jwt: "<JWT_HERE>", appIdentifier: "fiat-deposits"} }`: It will open the Fiat Deposits modal with the JWT provided
|
|
128
|
-
- `{type: "CLOSE_MODAL", payload:{appIdentifier: "fiat-deposits"}}`: It will close the Fiat Deposits modal
|
|
129
|
-
- **Fiat Withdrawals**
|
|
130
|
-
- `{type: "OPEN_MODAL", payload:{jwt: "<JWT_HERE>", appIdentifier: "fiat-withdrawals"} }`: It will open the Fiat withdrawals modal with the JWT provided
|
|
131
|
-
- `{type: "CLOSE_MODAL", payload:{appIdentifier: "fiat-withdrawals"}}`: It will close the Fiat withdrawals modal
|
|
132
|
-
- **Crypto Buy**
|
|
133
|
-
- `{type: "OPEN_MODAL", payload:{jwt: "<JWT_HERE>", appIdentifier: "crypto-buy"} }`: It will open the Crypto buy modal with the JWT provided
|
|
134
|
-
- `{type: "CLOSE_MODAL", payload:{appIdentifier: "crypto-buy"}}`: It will close the Crypto buy modal
|
|
135
|
-
- **Crypto Sell**
|
|
136
|
-
- `{type: "OPEN_MODAL", payload:{jwt: "<JWT_HERE>", appIdentifier: "crypto-sell"} }`: It will open the Crypto sell modal with the JWT provided
|
|
137
|
-
- `{type: "CLOSE_MODAL", payload:{appIdentifier: "crypto-sell"}}`: It will close the Crypto sell modal
|
|
138
|
-
|
|
139
|
-
#### Notes
|
|
140
|
-
A postMessage call is required to open the modal when the webview is loaded (type: OPEN_MODAL). This requirement was added in version `https://{SDK_SERVER_URL}/v1` and is not present in `https://{SDK_SERVER_URL}/`, which opens the onboarding app automatically. The latter will be deprecated and will not be available for use in the future.
|
|
141
|
-
|
|
142
|
-
To safely trigger the "OPEN_MODAL" event in the version 1, listen for an event sent by sdk-mobile indicating that the app is ready to receive events. This event generate by sdk-mobile is called **SDK_MOBILE_READY**.
|
|
143
|
-
|
|
144
|
-
The example below shows how you can implement the mentioned methods in a `react-native` project
|
|
145
|
-
|
|
146
|
-
```jsx
|
|
147
|
-
const sdkMobileServer = 'https://sdk-mobile.cert.zerohash.com/v1'
|
|
148
|
-
const zeroHashAppsURL = 'https://web-sdk.cert.zerohash.com/'
|
|
149
|
-
const App = () => {
|
|
150
|
-
const webViewRef = useRef<WebView>(null)
|
|
151
|
-
const [isWebViewOpen, setIsWebViewOpen] = React.useState(false)
|
|
152
|
-
const currentAppIdentifier = 'onboarding'
|
|
153
|
-
const mockJWT =
|
|
154
|
-
'eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJ6ZXJvaGFzaC5jb20iLCJzdWIiOiJ0ZXN0U3ViamVjdCIsImF1ZCI6WyJ6ZXJvaGFzaC5jb20iXSwiZXhwIjoxNjk1OTc2OTMzLCJpYXQiOjE2OTMzODQ5MzMsInBheWxvYWQiOnsiZW1haWwiOiJteS1lbWFpbEB0ZXN0LmNvbSIsInBhcnRpY2lwYW50X2NvZGUiOiJwYXJ0aWNpcGFudC1jb2RlIiwicGxhdGZvcm1fbmFtZSI6InBsYXRmb3JtLW5hbWUiLCJwbGF0Zm9ybV9jb2RlIjoicGxhdGZvcm0tY29kZSIsInBsYXRmb3JtX2FncmVlbWVudF9saW5rIjoicGxhdGZvcm0tYWdyZWVtZW50LWxpbmsifX0.r549t4J_iQ8wP5pnD2uTdRaRm4nHLO722lDmhbGoIc0E_cKVyVYnxZTO1DnXJ6NUJ6a3DvnkGv78iQHqvnFTmg'
|
|
155
|
-
const apps = {
|
|
156
|
-
fiatDeposits: { identifier: 'fiat-deposits', jwt: mockJWT },
|
|
157
|
-
cryptoBuy: { identifier: 'crypto-buy', jwt: mockJWT },
|
|
158
|
-
cryptoSell: { identifier: 'crypto-sell', jwt: mockJWT },
|
|
159
|
-
cryptoWithdrawals: { identifier: 'crypto-withdrawals', jwt: mockJWT },
|
|
160
|
-
fiatWithdrawals: { identifier: 'fiat-withdrawals', jwt: mockJWT },
|
|
161
|
-
userOnboarding: { identifier: 'onboarding', jwt: mockJWT },
|
|
162
|
-
}
|
|
163
|
-
/**
|
|
164
|
-
* Receive messages from sdk-mobile. Currently we expose the following event types:
|
|
165
|
-
* "ONBOARDING_APP_LOADED", "ONBOARDING_CLOSE_BUTTON_CLICKED",
|
|
166
|
-
* "CRYPTO_WITHDRAWALS_APP_LOADED", "CRYPTO_WITHDRAWALS_CLOSE_BUTTON_CLICKED",
|
|
167
|
-
* "FIAT_DEPOSITS_APP_LOADED", "FIAT_DEPOSITS_CLOSE_BUTTON_CLICKED",
|
|
168
|
-
* "FIAT_WITHDRAWALS_APP_LOADED", "FIAT_WITHDRAWALS_CLOSE_BUTTON_CLICKED",
|
|
169
|
-
* "CRYPTO_BUY_APP_LOADED", "CRYPTO_BUY_CLOSE_BUTTON_CLICKED",
|
|
170
|
-
* "CRYPTO_SELL_APP_LOADED", "CRYPTO_SELL_CLOSE_BUTTON_CLICKED",
|
|
171
|
-
* you should be able to take action based on these events.
|
|
172
|
-
*/
|
|
173
|
-
const handleMessage = (event: WebViewMessageEvent) => {
|
|
174
|
-
const closeModalEvents = [
|
|
175
|
-
'ONBOARDING_CLOSE_BUTTON_CLICKED',
|
|
176
|
-
'CRYPTO_WITHDRAWALS_CLOSE_BUTTON_CLICKED',
|
|
177
|
-
'FIAT_DEPOSITS_CLOSE_BUTTON_CLICKED',
|
|
178
|
-
'FIAT_WITHDRAWALS_CLOSE_BUTTON_CLICKED',
|
|
179
|
-
'CRYPTO_BUY_CLOSE_BUTTON_CLICKED',
|
|
180
|
-
'CRYPTO_SELL_CLOSE_BUTTON_CLICKED',
|
|
181
|
-
]
|
|
182
|
-
try {
|
|
183
|
-
const parsedMessage = JSON.parse(event.nativeEvent.data)
|
|
184
|
-
console.log('Received message:', parsedMessage)
|
|
185
|
-
if (closeModalEvents.includes(parsedMessage.type)) {
|
|
186
|
-
setIsWebViewOpen(false)
|
|
187
|
-
}
|
|
188
|
-
if (parsedMessage.type === 'SDK_MOBILE_READY') {
|
|
189
|
-
console.log('SDK is ready, opening modal...')
|
|
190
|
-
openModal()
|
|
191
|
-
}
|
|
192
|
-
} catch (e) {
|
|
193
|
-
alert(
|
|
194
|
-
`could not parse message: ${JSON.stringify(event.nativeEvent.data)}`,
|
|
195
|
-
)
|
|
196
|
-
}
|
|
197
|
-
}
|
|
198
|
-
/**
|
|
199
|
-
* You can also send messages to sdk-mobile, currently we accept the following messages:
|
|
200
|
-
* "OPEN_MODAL" and "CLOSE_MODAL"
|
|
201
|
-
* Note that the "true;" after the postMessage is required
|
|
202
|
-
* and recommended by the official react-native-webview docs
|
|
203
|
-
* https://github.com/react-native-webview/react-native-webview/blob/master/docs/Guide.md#the-injectedjavascript-prop
|
|
204
|
-
*/
|
|
205
|
-
const makeEventType = (
|
|
206
|
-
eventAppIdentifier: string,
|
|
207
|
-
eventType: string,
|
|
208
|
-
useJWT = false,
|
|
209
|
-
) => {
|
|
210
|
-
if (
|
|
211
|
-
!Object.entries(apps).some(
|
|
212
|
-
([_, { identifier }]) => identifier === eventAppIdentifier,
|
|
213
|
-
)
|
|
214
|
-
) {
|
|
215
|
-
throw new Error('Invalid app identifier')
|
|
216
|
-
}
|
|
217
|
-
if (useJWT) {
|
|
218
|
-
// You can send events with JWTs. See the example below
|
|
219
|
-
// { "type": "OPEN_MODAL", "payload": { "appIdentifier": "onboarding", "jwt": "some-jwt-token"}}
|
|
220
|
-
// { "type": "CLOSE_MODAL", "payload": { "appIdentifier": "onboarding", "jwt": "some-jwt-token"}}
|
|
221
|
-
return `{ "type": "${eventType}", "payload": { "appIdentifier": "${eventAppIdentifier}", "jwt": "${apps[eventAppIdentifier].jwt}"}}`
|
|
222
|
-
}
|
|
223
|
-
// Send events without JWTs if you already set in the URL with query parameters and don't want to send it again
|
|
224
|
-
// { "type": "OPEN_MODAL", "payload": { "appIdentifier": "onboarding"}}
|
|
225
|
-
// { "type": "CLOSE_MODAL", "payload": { "appIdentifier": "onboarding"}}
|
|
226
|
-
return `{ "type": "${eventType}", "payload": { "appIdentifier": "${eventAppIdentifier}"}}`
|
|
227
|
-
}
|
|
228
|
-
const openModal = () => {
|
|
229
|
-
setIsWebViewOpen(true)
|
|
230
|
-
webViewRef.current?.injectJavaScript(
|
|
231
|
-
`window.postMessage(${makeEventType(currentAppIdentifier, 'OPEN_MODAL')});true;`,
|
|
232
|
-
)
|
|
233
|
-
}
|
|
234
|
-
const closeModal = () => {
|
|
235
|
-
webViewRef.current?.injectJavaScript(
|
|
236
|
-
`window.postMessage(${makeEventType(currentAppIdentifier, 'CLOSE_MODAL')});true;`,
|
|
237
|
-
)
|
|
238
|
-
}
|
|
239
|
-
/**
|
|
240
|
-
* Generate the URL with the query parameters required and the JWTs for the apps
|
|
241
|
-
*/
|
|
242
|
-
const generateURL = () => {
|
|
243
|
-
const jwtParams = Object.entries(apps)
|
|
244
|
-
.filter(([_, { jwt }]) => jwt)
|
|
245
|
-
.map(([key, { jwt }]) => `${key}JWT=${encodeURIComponent(jwt)}`)
|
|
246
|
-
.join('&')
|
|
247
|
-
|
|
248
|
-
return `${sdkMobileServer}?zeroHashAppsURL=${encodeURIComponent(zeroHashAppsURL)}&${jwtParams}`
|
|
249
|
-
}
|
|
250
|
-
return (
|
|
251
|
-
<SafeAreaProvider style={{ flex: 1 }}>
|
|
252
|
-
<SafeAreaView
|
|
253
|
-
style={{
|
|
254
|
-
flex: 1,
|
|
255
|
-
padding: 0,
|
|
256
|
-
}}
|
|
257
|
-
>
|
|
258
|
-
{!isWebViewOpen && (
|
|
259
|
-
<View
|
|
260
|
-
style={{
|
|
261
|
-
flex: 1,
|
|
262
|
-
alignContent: 'center',
|
|
263
|
-
flexDirection: 'row',
|
|
264
|
-
justifyContent: 'center',
|
|
265
|
-
alignItems: 'center',
|
|
266
|
-
}}
|
|
267
|
-
>
|
|
268
|
-
<TouchableOpacity
|
|
269
|
-
style={{
|
|
270
|
-
backgroundColor: '#00f197',
|
|
271
|
-
padding: 10,
|
|
272
|
-
margin: 10,
|
|
273
|
-
borderRadius: 5,
|
|
274
|
-
alignItems: 'center',
|
|
275
|
-
justifyContent: 'center',
|
|
276
|
-
}}
|
|
277
|
-
onPress={() => setIsWebViewOpen(true)}
|
|
278
|
-
>
|
|
279
|
-
<Text>Open modal</Text>
|
|
280
|
-
</TouchableOpacity>
|
|
281
|
-
<TouchableOpacity
|
|
282
|
-
style={{
|
|
283
|
-
backgroundColor: '#00f197',
|
|
284
|
-
padding: 10,
|
|
285
|
-
margin: 10,
|
|
286
|
-
borderRadius: 5,
|
|
287
|
-
alignItems: 'center',
|
|
288
|
-
justifyContent: 'center',
|
|
289
|
-
}}
|
|
290
|
-
onPress={() => closeModal()}
|
|
291
|
-
>
|
|
292
|
-
<Text>Close modal</Text>
|
|
293
|
-
</TouchableOpacity>
|
|
294
|
-
</View>
|
|
295
|
-
)}
|
|
296
|
-
<View style={{ display: isWebViewOpen ? 'flex' : 'none', flex: 1 }}>
|
|
297
|
-
{isWebViewOpen && (
|
|
298
|
-
<WebView
|
|
299
|
-
ref={webViewRef}
|
|
300
|
-
onMessage={handleMessage}
|
|
301
|
-
source={{ uri: generateURL() }}
|
|
302
|
-
/>
|
|
303
|
-
)}
|
|
304
|
-
</View>
|
|
305
|
-
</SafeAreaView>
|
|
306
|
-
</SafeAreaProvider>
|
|
307
|
-
)
|
|
308
|
-
}
|
|
309
|
-
export default App
|
|
310
|
-
```
|
|
51
|
+
## Mobile Usage
|
|
52
|
+
For more details on how to use it on mobile apps, please refer to our full documentation:
|
|
53
|
+
[ZeroHash SDK Documentation](https://docs.zerohash.com/reference/sdk-overview).
|