forked from onfido/WebViewRN
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathApp.js
49 lines (42 loc) · 1.31 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
/**
* Sample React Native App
* https://github.com/facebook/react-native
*
* @format
* @flow strict-local
*/
import React, { Component } from 'react';
import {
SafeAreaView,
} from 'react-native';
import { WebView } from 'react-native-webview';
class App extends Component {
render() {
const runFirst = `
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/755350ab-4ed2-4e4f-8834-d57c98513658' }}
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>
);
}
}
export default App;