[英]Share AsyncStorage from iOS react native app with Apple Watch
I'm developing the main app with react native and the Apple Watch with Swift. 我正在使用react native开发主要应用程序,并使用Swift开发Apple Watch。
The main app (react native) uses AsyncStorage to store some values, that then are used as params for a fetch that shows a list. 主应用程序(反应本机)使用AsyncStorage存储一些值,然后将这些值用作显示列表的访存的参数。
After running the simulator, I found manifest.json inside 运行模拟器后,我在里面找到manifest.json
~/Library/Developer/CoreSimulator/Devices/D10E869B-040B-446F-9B8B-754F111442EC/data/Containers/Data/Application/AC837AFE-312B-4861-906D-EC9EEE7D029B/Document s/RCTAsyncLocalStorage_V1
with the data inside. 里面的数据。
I need to access those values in the Apple Watch in Xcode to do the same job as the iOS app. 我需要在Xcode的Apple Watch中访问这些值,以完成与iOS应用程序相同的工作。 How do I access that data? 如何访问这些数据?
Since Apple Watch apps run independently from iOS app since watchOS 2, there's really no way to directly access the data stored locally on iPhone — you'll need to maintain some form of communication between your iOS and watchOS apps. 由于Apple Watch应用程序自watchOS 2起独立于iOS应用程序运行,因此实际上无法直接访问iPhone本地存储的数据-您需要在iOS和watchOS应用程序之间保持某种形式的通信。
The framework intended for this is called WatchConnectivity . 用于此目的的框架称为WatchConnectivity 。 I see two more-or-less suitable solutions for your case: 我看到两种或多或少适合您的情况的解决方案:
Unfortunately, I don't know how WatchConnectivity is supposed to work with ReactNative. 不幸的是,我不知道WatchConnectivity应该如何与ReactNative一起工作。 If you want a deeper introduction to this framework — I highly recommend watching this amazing video from WWDC 2015. 如果您想对该框架进行更深入的介绍,我强烈建议您观看WWDC 2015的精彩视频 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.