-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathApp.js
79 lines (68 loc) · 2.16 KB
/
App.js
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
/**
* Sample React Native App
* https://github.com/facebook/react-native
*
* @format
* @flow strict-local
*/
import React, { Component } from 'react';
import {
SafeAreaView,
Text,
} from 'react-native';
import { WebView } from 'react-native-webview';
class App extends Component {
render() {
const runFirst = `
document.body.style.backgroundColor = 'red';
onfido.setOptions({onComplete: () => window.ReactNativeWebView.postMessage("onComplete"),onError: () => window.ReactNativeWebView.postMessage("onError")});
true; // note: this is required, or you'll sometimes get silent failures
`;
return (
<SafeAreaView style={{ flex: 1 }}>
<WebView
allowsInlineMediaPlayback={true}
source={{ uri: 'https://crowd-testing.eu.onfido.app/f/f0d19ecd-c0c2-4790-a286-084571410e1c' }}
onMessage={(event) => {
if(event.nativeEvent.data === 'onComplete'){
alert("we have comepleted")
//onComplete callback goes here
} else if (event.nativeEvent.data === 'onError') {
alert("we have an Error")
//onError callback goes here
} else {
alert("Do nothing")
//do something else
}
}}
injectedJavaScript={runFirst}
/>
</SafeAreaView>
);
}
/******
*
* Example usinf latest hosted SDK with standard step configs no workflow
* Replace <SDK_TOKEN> with valid SDK token
*
* render() {
*
const runFirst = `
document.body.style.backgroundColor = 'red';Onfido.init({containerEl: document.body,token:<SDK_TOKEN>});document.querySelector("#spinner")?.remove();
true; // note: this is required, or you'll sometimes get silent failures
`;
return (
<SafeAreaView style={{ flex: 1 }}>
<WebView
originWhitelist={['*']}
allowsInlineMediaPlayback={true}
source={{ uri: 'https://sdk.eu.onfido.app/frame' }}
injectedJavaScript={runFirst}
useWebKit={true}
/>
</SafeAreaView>
);
}
*/
}
export default App;