简体   繁体   English

Android / iOS-BLE-BLE设备连接时唤醒终止的应用程序

[英]Android / iOS - BLE - wake up a terminated application when a BLE device connects

Iam creating an iOS and an Android application that read some data from a bluetooth sensor and saves them in a db. 我创建了一个iOS和一个Android应用程序,它们从蓝牙传感器读取一些数据并将其保存在数据库中。

I want to give the ability to save the sensor's data even when the application is terminated. 我想提供即使在应用程序终止时也可以保存传感器数据的功能。

fyi. 仅供参考。 I have already managed to read the sensor in both iOS and Android while the app is the background. 我已经设法在背景为iOS和Android的情况下读取传感器。

But my concern is on how to make the following scenario work: 但是我担心的是如何使以下情况起作用:

-Sensor is disconnected from the phone -User terminates the application from the task manager -User connects (and pairs) the BLE sensor to the device -The application wakes-up in the background and reads the sensor's output and then goes back to sleep. -传感器与电话断开连接-用户从任务管理器中终止应用程序-用户将BLE传感器连接(并配对)到设备-应用程序在后台唤醒并读取传感器的输出,然后返回睡眠状态。

Any suggestions? 有什么建议么?

For iOS this is possible as described in Apple doc Core Bluetooth Background Processing for iOS Apps . 对于iOS,这是可行的,如Apple文档iOS应用的Core蓝牙后台处理中所述

For Android you could start a Service (by your app and also on device boot) and (re)connect to the device. 对于Android,您可以(通过您的应用程序以及在设备启动时)启动服务 ,然后(重新)连接到设备。

Also you could post a local notification in iOS/Android background Service - and when the user touches it, start the BLE app. 您也可以在iOS / Android后台服务中发布本地通知-当用户触摸该通知时,启动BLE应用。

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

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