Implementation
The following is an example MetaMapPage class with the MetaMap method implementation:
import React, {Component} from 'react';
import {
NativeModules,
NativeEventEmitter,
Button,
View
} from 'react-native';
import {
MetaMapRNSdk,
} from 'react-native-metamap-sdk';
export default class App extends Component {
constructor() {
super();
console.log('Constructor Called.');
}
componentDidMount() {
//set listening callbacks
const MetaMapVerifyResult = new NativeEventEmitter(NativeModules.MetaMapRNSdk)
MetaMapVerifyResult.addListener('verificationSuccess', (data) => console.log(data))
MetaMapVerifyResult.addListener('verificationCanceled', (data) => console.log(data))
}
//call showFlow when button is clicked
handleMetaMapClickButton = () => {
MetaMapRNSdk.showFlow("YOUR_CLIENT_ID", "YOUR_FLOW_ID", {:});
}
render() {
return (
<View
style={{
flex: 1,
justifyContent: 'center',
alignItems: 'center',
backgroundColor: 'powderblue',
}}>
<Button onPress={this.handleMetaMapClickButton} title="Click here"/>
</View>
);
}
}
import React, {Component, useEffect} from 'react';
import {
NativeModules,
NativeEventEmitter,
Button,
View
} from 'react-native';
import {
MetaMapRNSdk,
} from 'react-native-metamap-sdk';
function App(props) {
useEffect(() => {
const MetaMapVerifyResult = new NativeEventEmitter(NativeModules.MetaMapRNSdk)
MetaMapVerifyResult.addListener('verificationSuccess', (data) => console.log(data))
MetaMapVerifyResult.addListener('verificationCanceled', (data) => console.log(data))
})
const handleMetaMapClickButton = (props) => {
MetaMapRNSdk.showFlow("YOUR_CLIENT_ID", "YOUR_FLOW_ID", {:});
}
return (
<View
style={{
flex: 1,
justifyContent: 'center',
alignItems: 'center',
backgroundColor: 'powderblue',
}}>
<Button onPress = {() => handleMetaMapClickButton()} title="Click here"/>
</View>
);
}
export default App;
Updated 12 months ago