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-expo-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))
}
handleMetaMapClickButton = () => {
MetaMapRNSdk.showFlow("YOUR_CLIENT_ID", "YOUR_FLOW_ID", {:});
}
//Add button to view graph
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-expo-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("610b96fb7cc893001b135505", "611101668083a1001b13cc80", {:});
}
return (
<View
style={{
flex: 1,
justifyContent: 'center',
alignItems: 'center',
backgroundColor: 'powderblue',
}}>
<Button onPress = {() => handleMetaMapClickButton()} title="Click here"/>
</View>
);
}
export default App;
Updated 11 months ago