IOS 上后台任务的 React-native 本机模块可能性
React-native native module possibilities for background task on IOS
我的问题:我有一个与医疗 BLE 设备通信的应用程序。我一切正常,但我的问题是,当 ios 用户将应用程序置于后台时,我会停止 getting/processing 通过蓝牙发送的消息。 Android 似乎不断收到这些消息,但根据我的发现,在 iOS 上,JS 桥已被拆除,并且没有针对此问题的解决方案。 phone 必须继续处理从 BLE 设备发送的数据。
我的想法是这样的,这是我想问大家的问题。
是否可以为 ios 创建一个始终为 运行 的本机模块并执行以下操作:在收到通知时获取 ble 数据。将该数据存储到文件系统并在应用程序处于后台时将其推送到网络服务?如果能够读取 fs 创建的文件并在应用程序返回前台时显示有关它们的一些数据,那也很棒。这可能吗?
您知道其他可行的选择吗?
非常感谢任何帮助。
您必须在 Xcode 项目设置中启用 iOS 后台模式功能。
另请查看 react-native-ble-plx,它为 iOS 和 Android 提供后台支持。
好的,当我沿着本机路径前进并阅读 ios 蓝牙 schtuff 时,我找到了这篇文章 Core Bluetooth Programming Guide,特别是它提到了 plist 设置。
The Core Bluetooth background execution modes are declared by adding the UIBackgroundModes key to your Info.plist file and setting the key’s value to an array containing one of the following strings:
bluetooth-central —The app communicates with Bluetooth low energy peripherals using the Core Bluetooth framework.
bluetooth-peripheral —The app shares data using the Core Bluetooth framework.
所以我心想,只要将这些密钥添加到我的 xcode 项目中,iOS 就足够聪明了,而不在乎我是 RN 应用程序而不是本地人......那是票!我插入这些值,即使我打开另一个应用程序也会处理 ble 数据。 "Wallah!";)
我的问题:我有一个与医疗 BLE 设备通信的应用程序。我一切正常,但我的问题是,当 ios 用户将应用程序置于后台时,我会停止 getting/processing 通过蓝牙发送的消息。 Android 似乎不断收到这些消息,但根据我的发现,在 iOS 上,JS 桥已被拆除,并且没有针对此问题的解决方案。 phone 必须继续处理从 BLE 设备发送的数据。
我的想法是这样的,这是我想问大家的问题。 是否可以为 ios 创建一个始终为 运行 的本机模块并执行以下操作:在收到通知时获取 ble 数据。将该数据存储到文件系统并在应用程序处于后台时将其推送到网络服务?如果能够读取 fs 创建的文件并在应用程序返回前台时显示有关它们的一些数据,那也很棒。这可能吗?
您知道其他可行的选择吗?
非常感谢任何帮助。
您必须在 Xcode 项目设置中启用 iOS 后台模式功能。
另请查看 react-native-ble-plx,它为 iOS 和 Android 提供后台支持。
好的,当我沿着本机路径前进并阅读 ios 蓝牙 schtuff 时,我找到了这篇文章 Core Bluetooth Programming Guide,特别是它提到了 plist 设置。
The Core Bluetooth background execution modes are declared by adding the UIBackgroundModes key to your Info.plist file and setting the key’s value to an array containing one of the following strings: bluetooth-central —The app communicates with Bluetooth low energy peripherals using the Core Bluetooth framework. bluetooth-peripheral —The app shares data using the Core Bluetooth framework.
所以我心想,只要将这些密钥添加到我的 xcode 项目中,iOS 就足够聪明了,而不在乎我是 RN 应用程序而不是本地人......那是票!我插入这些值,即使我打开另一个应用程序也会处理 ble 数据。 "Wallah!";)