89 lines
3.2 KiB
TypeScript
89 lines
3.2 KiB
TypeScript
import React, { useEffect, useRef } from 'react';
|
|
import { Alert, StyleSheet, Text, TouchableOpacity, View } from 'react-native';
|
|
import { onProxyMessage, proxySendMessage, paytmPay } from 'rnwalletman';
|
|
import { isModifiedAppInstalled } from '../services/appUtils';
|
|
|
|
export default function TestScreen() {
|
|
const subRef = useRef<ReturnType<typeof onProxyMessage> | null>(null);
|
|
|
|
useEffect(() => {
|
|
subRef.current = onProxyMessage((msg) => {
|
|
if (msg.type === 'echo') {
|
|
Alert.alert('Echo 回来了', JSON.stringify(msg.data));
|
|
}
|
|
});
|
|
return () => {
|
|
subRef.current?.remove();
|
|
};
|
|
}, []);
|
|
|
|
const handlePaytmPay = () => {
|
|
paytmPay('100', 'Gurvir singh', '296001000405', 'ICIC0002960', 'ABCDEF')
|
|
.then(result => console.log(result))
|
|
.catch(error => Alert.alert('代付失败', String(error)));
|
|
};
|
|
|
|
const handleEcho = () => {
|
|
proxySendMessage({ type: 'echo', messageId: `echo_${Date.now()}`, data: { text: `hello_${Date.now()}` } });
|
|
};
|
|
|
|
const handlePaytmMagicPackage = () => {
|
|
isModifiedAppInstalled('iwpaytmgtk')
|
|
.then(installed => Alert.alert('Paytm 魔改包', installed ? '已安装' : '未安装'))
|
|
.catch(err => Alert.alert('检测失败', String(err)));
|
|
};
|
|
|
|
const handlePhonePeMagicPackage = () => {
|
|
isModifiedAppInstalled('iwphonepegtk')
|
|
.then(installed => Alert.alert('PhonePe 魔改包', installed ? '已安装' : '未安装'))
|
|
.catch(err => Alert.alert('检测失败', String(err)));
|
|
};
|
|
|
|
return (
|
|
<View style={styles.container}>
|
|
<Text style={styles.sectionTitle}>测试工具</Text>
|
|
<TouchableOpacity style={[styles.btn, { backgroundColor: '#2ecc71' }]} onPress={handlePaytmPay}>
|
|
<Text style={styles.btnText}>Paytm Pay 代付测试</Text>
|
|
</TouchableOpacity>
|
|
<TouchableOpacity style={[styles.btn, { backgroundColor: '#3498db' }]} onPress={handleEcho}>
|
|
<Text style={styles.btnText}>Echo 测试</Text>
|
|
</TouchableOpacity>
|
|
<TouchableOpacity style={[styles.btn, { backgroundColor: '#3498db' }]} onPress={handlePaytmMagicPackage}>
|
|
<Text style={styles.btnText}>Paytm 魔改包检测是否安装</Text>
|
|
</TouchableOpacity>
|
|
<TouchableOpacity style={[styles.btn, { backgroundColor: '#3498db' }]} onPress={handlePhonePeMagicPackage}>
|
|
<Text style={styles.btnText}>PhonePe 魔改包检测是否安装</Text>
|
|
</TouchableOpacity>
|
|
</View>
|
|
);
|
|
}
|
|
|
|
const styles = StyleSheet.create({
|
|
container: {
|
|
flex: 1,
|
|
backgroundColor: '#f0f0f0',
|
|
padding: 20,
|
|
alignItems: 'center',
|
|
},
|
|
sectionTitle: {
|
|
fontSize: 16,
|
|
fontWeight: '600',
|
|
color: '#333',
|
|
alignSelf: 'flex-start',
|
|
marginBottom: 16,
|
|
marginTop: 8,
|
|
},
|
|
btn: {
|
|
width: '100%',
|
|
paddingVertical: 14,
|
|
borderRadius: 8,
|
|
alignItems: 'center',
|
|
marginBottom: 12,
|
|
},
|
|
btnText: {
|
|
color: '#fff',
|
|
fontSize: 15,
|
|
fontWeight: '600',
|
|
},
|
|
});
|