ios - IOS 后台任务的 React-native native 模块可能性

标签 ios react-native bluetooth-lowenergy background-process react-native-ios

我的问题:我有一个与医疗 BLE 设备通信的应用程序。我一切正常,但我的问题是,当 ios 用户将应用程序置于后台时,我停止获取/处理通过蓝牙发送的消息。 Android 似乎不断收到这些消息,但据我发现,在 iOS 上,JS 桥已被拆除,并且没有针对此问题的解决方案。手机必须继续处理从 BLE 设备发送的数据。

我的想法是这样,这是我对你们所有人的问题。
是否可以为 ios 创建一个始终运行并执行以下操作的 native 模块:在收到通知时获取 ble 数据。将这些数据存储到文件系统并在应用程序处于后台时将其推送到 Web 服务?能够读取 fs 创建的文件并在应用程序返回前台时显示有关它们的一些数据的能力也很棒。这可能吗?

你知道另一个可行的选择吗?

任何帮助是极大的赞赏。

最佳答案

好的,当我沿着 native 路径前进并阅读 ios bluetooth 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 数据。 “哇!” ;)

关于ios - IOS 后台任务的 React-native native 模块可能性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49802451/

相关文章:

android - React Native - 在 View 之间传递数据

javascript - React-native:覆盖外部组件的样式

react-native - React Native Expo 任务管理器

android - 用 Greenrobot Eventbus 替换广播接收器是否可以触发基于事件的功能和从服务到 Activity 的数据传输?

ios - 蓝牙 Controller 列出多个版本的设备 - Swift 3.1

Android 手机从蓝牙更改为 BLE 后无法连接树莓派

ios - AES256 加密在 node.js 和 objective-c 之间得到不同的结果

ios - 如何在 UICollectionView 中隐藏一个部分

ios - 在 Xcode cocos2d 中添加多个物理对象时遇到问题

ios - 在 iOS 应用程序的整个 Web View 中保留登录凭据(快速)