Skip to content

Commit 940622b

Browse files
committed
docs: update example usage
1 parent d9a53a2 commit 940622b

File tree

2 files changed

+64
-32
lines changed

2 files changed

+64
-32
lines changed

README.md

Lines changed: 27 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,37 @@ npm install react-native-idscan-sdk
1111
## Usage
1212

1313
```js
14+
import { TouchableOpacity, Text } from 'react-native'
1415
import { scan, IDScanner_Constants } from 'react-native-idscan-sdk';
1516

1617
// ...
1718

18-
const result = await scan(
19-
IDScanner_Constants.TYPE_PDF, // TYPE_ALL, TYPE_MRZ, TYPE_PDF
20-
'CAMERA_KEY_HERE',
21-
'PARSER_KEY_HERE',
22-
(error, scannedData) => console.log(error, scannedData)
23-
);
19+
const onScanID = () => {
20+
scan(
21+
IDScanner_Constants.TYPE_PDF, // TYPE_ALL, TYPE_MRZ, TYPE_PDF
22+
{
23+
// iOS
24+
iosDetectorPDFLicenseKey: 'iOS IdScanner PDF License Key here',
25+
iosDetectorMRZLicenseKey: 'iOS IdScanner MRZ License Key here',
26+
iosParserPDFLicenseKey: 'iOS IdParser PDF License Key here',
27+
28+
// Android
29+
androidDetectorPDFLicenseKey: 'android IdScanner PDF License Key here',
30+
androidDetectorMRZLicenseKey: 'android IdScanner MRZ License Key here',
31+
androidParserPDFLicenseKey: 'android IdParser PDF License Key here',
32+
}
33+
(error, scannedData) => console.log(error, scannedData)
34+
);
35+
}
36+
37+
// ...
38+
39+
<TouchableOpacity
40+
onPress={onScanID}
41+
>
42+
<Text>Scan My ID</Text>
43+
</TouchableOpacity>
44+
2445
```
2546

2647
## iOS Quirks

example/src/App.tsx

Lines changed: 37 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,52 @@
1-
import * as React from 'react';
1+
import React from 'react';
22

3-
import { StyleSheet, View, Text } from 'react-native';
3+
import { StyleSheet, View, Text, TouchableOpacity } from 'react-native';
44
import { scan, IDScanner_Constants } from 'react-native-idscan-sdk';
55

66
export default function App() {
77
const [result, setResult] = React.useState<object | undefined>();
88

9-
React.useEffect(() => {
10-
setTimeout(() => {
11-
scan(
12-
IDScanner_Constants.TYPE_PDF,
13-
{
14-
// iOS
15-
iosDetectorPDFLicenseKey: 'iOS IdScanner PDF License Key here',
16-
iosDetectorMRZLicenseKey: 'iOS IdScanner MRZ License Key here',
17-
iosParserPDFLicenseKey: 'iOS IdParser PDF License Key here',
9+
// methods
10+
const triggerScanner = () => {
11+
scan(
12+
IDScanner_Constants.TYPE_PDF,
13+
{
14+
// iOS
15+
iosDetectorPDFLicenseKey: 'iOS IdScanner PDF License Key here',
16+
iosDetectorMRZLicenseKey: 'iOS IdScanner MRZ License Key here',
17+
iosParserPDFLicenseKey: 'iOS IdParser PDF License Key here',
1818

19-
// Android
20-
androidDetectorPDFLicenseKey:
21-
'android IdScanner PDF License Key here',
22-
androidDetectorMRZLicenseKey:
23-
'android IdScanner MRZ License Key here',
24-
androidParserPDFLicenseKey: 'android IdParser PDF License Key here',
25-
},
26-
(error, data) => {
27-
console.log(error, data);
19+
// Android
20+
androidDetectorPDFLicenseKey: 'android IdScanner PDF License Key here',
21+
androidDetectorMRZLicenseKey: 'android IdScanner MRZ License Key here',
22+
androidParserPDFLicenseKey: 'android IdParser PDF License Key here',
23+
},
24+
(error, data) => {
25+
console.log(error, data);
2826

29-
if (!error) {
30-
setResult(data);
31-
}
27+
if (!error) {
28+
setResult(data);
3229
}
33-
);
34-
}, 5000);
35-
}, []);
30+
}
31+
);
32+
};
3633

3734
return (
3835
<View style={styles.container}>
36+
<TouchableOpacity
37+
onPress={triggerScanner}
38+
style={{
39+
width: 200,
40+
height: 40,
41+
backgroundColor: '#a2f6a5',
42+
alignItems: 'center',
43+
justifyContent: 'center',
44+
marginBottom: 10,
45+
borderRadius: 5,
46+
}}
47+
>
48+
<Text>Scan ID</Text>
49+
</TouchableOpacity>
3950
<Text>Result: {JSON.stringify(result)}</Text>
4051
</View>
4152
);

0 commit comments

Comments
 (0)