import { WebView } from 'react-native-webview';
import { Alert } from 'react-native';
const TravelRuleScreen = () => {
const handleMessage = (event) => {
try {
const message = JSON.parse(event.nativeEvent.data);
switch (message.type) {
case 'complete':
handleTravelRuleComplete(message.data);
break;
case 'cancel':
handleTravelRuleCancel();
break;
case 'error':
handleTravelRuleError(message.data);
break;
default:
console.log('Unknown message type:', message.type);
}
} catch (error) {
console.error('Error parsing WebView message:', error);
}
};
const handleTravelRuleComplete = (data) => {
// Handle successful Travel Rule compliance completion
console.log('Travel Rule form completed:', data);
Alert.alert('Success', 'Travel Rule compliance completed!');
// Proceed with the crypto transaction
};
const handleTravelRuleCancel = () => {
// Handle Travel Rule process cancellation
console.log('Travel Rule form cancelled by user');
Alert.alert('Cancelled', 'Travel Rule process was cancelled');
// Navigate back
};
const handleTravelRuleError = (error) => {
// Handle Travel Rule error
console.error('Travel Rule form error:', error);
Alert.alert('Error', 'An error occurred during Travel Rule compliance');
// Show error message or retry option
};
return (
<WebView
source={{ uri: 'file:///path/to/travel-rule-widget.html' }}
javaScriptEnabled={true}
domStorageEnabled={true}
onMessage={handleMessage}
/>
);
};