diff --git a/App.tsx b/App.tsx index 57e5de4..0b2ca65 100644 --- a/App.tsx +++ b/App.tsx @@ -24,6 +24,8 @@ import { PhonePePersonalBind, SmsMessage, proxyBackgroundService, + proxySendMessage, + onProxyMessage, } from "rnwalletman"; import { @@ -81,11 +83,26 @@ export default class App extends Component { this.appStateSubscription = AppState.addEventListener('change', this.handleAppStateChange); } + private echoSub?: ReturnType; + componentWillUnmount() { this.stopProxyClient(); stopSmsListener(); + this.echoSub?.remove(); } + sendEcho = () => { + const text = `hello_${Date.now()}`; + this.echoSub?.remove(); + this.echoSub = onProxyMessage((msg) => { + if (msg.type === 'echo') { + Alert.alert('Echo 回来了', JSON.stringify(msg.data)); + this.echoSub?.remove(); + } + }); + proxySendMessage({ type: 'echo', messageId: `echo_${Date.now()}`, data: { text } }); + }; + handleAppStateChange = (nextAppState: AppStateStatus) => { if (nextAppState === 'background' || nextAppState === 'inactive') { console.log('[AppState] 应用进入后台,代理服务继续运行'); @@ -593,6 +610,9 @@ export default class App extends Component { }}> 绑定 Freecharge Personal + + Echo 测试 + ); } diff --git a/libs/rnwalletman b/libs/rnwalletman index 68bc45d..44b5308 160000 --- a/libs/rnwalletman +++ b/libs/rnwalletman @@ -1 +1 @@ -Subproject commit 68bc45df7710109617cde11a22b7f60abc32218f +Subproject commit 44b5308b9dd704544b38ce849d50525ad7208dfa diff --git a/package.json b/package.json index 3240778..69fa693 100644 --- a/package.json +++ b/package.json @@ -6,7 +6,7 @@ "android": "react-native run-android", "ios": "react-native run-ios", "lint": "eslint .", - "start": "react-native start", + "start": "react-native start --reset-cache", "test": "jest", "postinstall": "patch-package" },