-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathApp.js
More file actions
49 lines (43 loc) · 1.23 KB
/
App.js
File metadata and controls
49 lines (43 loc) · 1.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
import React from 'react';
import {NativeModules, NativeEventEmitter, Button, View} from 'react-native';
const {GetID} = NativeModules;
const GetIDEmitter = new NativeEventEmitter(GetID);
GetIDEmitter.addListener('GetIDEvent', (body) => console.log(body));
const VerifyButton = () => {
// Note: Don't use your SDK key in the client-side code in the production environment.
const apiUrl = 'API_URL';
const sdkKey = 'SDK_KEY';
const flowName = 'getid-doc-selfie';
const getToken = () => {
return fetch(apiUrl + '/sdk/v2/token', {
method: 'POST',
headers: {
Accept: 'application/json',
'Content-Type': 'application/json',
'x-sdk-key': sdkKey,
},
});
};
const onPress = () => {
getToken()
.then((response) => response.json())
.then((json) => {
GetID.start(apiUrl, json.token, flowName);
});
};
return (
<View
style={[
// eslint-disable-next-line react-native/no-inline-styles
{
marginLeft: 20,
marginTop: 100,
marginRight: 20,
backgroundColor: 'white',
},
]}>
<Button title="Verify me!" color="blue" onPress={onPress} />
</View>
);
};
export default VerifyButton;