|
1 | | -import * as React from 'react'; |
| 1 | +import React from 'react'; |
2 | 2 |
|
3 | | -import { StyleSheet, View, Text } from 'react-native'; |
| 3 | +import { StyleSheet, View, Text, TouchableOpacity } from 'react-native'; |
4 | 4 | import { scan, IDScanner_Constants } from 'react-native-idscan-sdk'; |
5 | 5 |
|
6 | 6 | export default function App() { |
7 | 7 | const [result, setResult] = React.useState<object | undefined>(); |
8 | 8 |
|
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', |
18 | 18 |
|
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); |
28 | 26 |
|
29 | | - if (!error) { |
30 | | - setResult(data); |
31 | | - } |
| 27 | + if (!error) { |
| 28 | + setResult(data); |
32 | 29 | } |
33 | | - ); |
34 | | - }, 5000); |
35 | | - }, []); |
| 30 | + } |
| 31 | + ); |
| 32 | + }; |
36 | 33 |
|
37 | 34 | return ( |
38 | 35 | <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> |
39 | 50 | <Text>Result: {JSON.stringify(result)}</Text> |
40 | 51 | </View> |
41 | 52 | ); |
|
0 commit comments