简体   繁体   English

与 Android Wear 的 React-Native 通信

[英]React-Native communication with Android Wear

I currently have a react-native app with an android wear module.我目前有一个带有 android 磨损模块的 react-native 应用程序。 The RN app is able to communicate with the wear app through the use of Native Modules. RN 应用程序能够通过使用本机模块与穿戴应用程序进行通信。 The wear app is able to communicate with the RN app by sending events to the javascript using RCTDeviceEventEmitter.通过使用 RCTDeviceEventEmitter 向 javascript 发送事件,Wear 应用程序能够与 RN 应用程序进行通信。 The communication from wear to RN works, as long as the RN app is running, either on screen or in background.只要 RN 应用程序正在运行,无论是在屏幕上还是在后台,从 Wear 到 RN 的通信都会起作用。

The Native code runs and logs all the way up until it gets to the ReactContextBaseJavaModule, so the code, even on the native mobile side, is running, just not the React classes.本机代码一直运行并记录,直到它到达 ReactContextBaseJavaModule,所以即使在本机移动端,代码也在运行,而不是 React 类。 Is there a way for me to communicate with the RN javascript, if the app is closed?如果应用程序关闭,我有没有办法与 RN javascript 通信?

Check out the below repo.查看下面的回购。 It has explained how it works too:它也解释了它是如何工作的:

https://github.com/bevkoski/react-native-android-wear-demo/tree/capability-api https://github.com/bevkoski/react-native-android-wear-demo/tree/capability-api

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM