This repository was archived by the owner on Aug 16, 2025. It is now read-only.
forked from vvorld/getid-react-native-example
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathApp.js
More file actions
45 lines (38 loc) · 1.11 KB
/
App.js
File metadata and controls
45 lines (38 loc) · 1.11 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
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={[{ marginLeft: 20, marginTop: 100, marginRight: 20, backgroundColor: "white" }]}>
<Button
title="Verify me!"
color="blue"
onPress={onPress}
/>
</View>
);
};
export default VerifyButton;