简体   繁体   English

如何知道当应用程序在后台且其在ios系统中首先连接时何时检索连接的ble设备?

[英]How to know when to retrieve connected ble device while app is in background and its connected first in ios system?

Our BLE device is using ANCS and being connected as peripheral in the ios app. 我们的BLE设备正在使用ANCS并作为ios应用程序中的外围设备进行连接。 My problem happens in case when watch is being connected in settings screen first then it doesnt show up in scanned device thats why its not connecting while app is in background because its getting connected outside of the app, reason being iphone is bonded with ble device. 我的问题发生在万一手表首先在设置屏幕中连接,然后它没有出现在扫描设备中的情况下,这就是为什么它在应用程序处于后台时未连接的原因,因为它在应用程序外部进行了连接,原因是iPhone与ble设备绑定了。 Though I can retrieve it using retrievePeripheral function . 虽然我可以使用retrievePeripheral函数来检索它。 But it has to be manually fired , I am looking for some kind of observer or delegate function which is called when a BLE device is called through system so I can retrieve peripheral. 但是它必须手动触发,我正在寻找某种通过系统调用BLE设备时调用的观察者或委托函数,以便我可以检索外围设备。 How to connect while app is in background and ble device is connected in Settings first? 当应用程序处于后台并且先在“设置”中连接设备时如何连接? One solution I was thinking is run a timer which will call this retrievePeripheral function after a fixed interval, but that will be battery consuming. 我在想的一种解决方案是运行一个计时器,该计时器将在固定的时间间隔后调用此retrievePeripheral函数,但这会消耗电池。 If anybody have better idea please enlighten me. 如果有人有更好的主意,请赐教。

I have tried almost everything , I know scan function works in background with service ids but I am talking about the scenario where device is undiscoverable as it got connected in settings screen first. 我已经尝试了几乎所有方法,我知道扫描功能可在具有服务ID的后台运行,但我所谈论的是设备在设置屏幕中首次连接时无法发现的情况。

Seems like I don't need to scan for device once its discovered, connected and successfully paired. 似乎一旦发现,连接并成功配对后,我就无需扫描设备。 In didDisconnect function I am retrieveing the ble device and sending a connect request See this , this function doesn't time out. 在didDisconnect函数中,我正在检索ble设备并发送连接请求。 请参见此,该函数不会超时。 Whenever BLE device will come into the range it will be connected. 只要BLE设备进入该范围,它将被连接。

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

相关问题 iOS:在应用程序处于后台时监控连接到Wifi设备的套接字 - iOS: Monitor a Socket Connected to a Wifi Device while app is in Background 我怎么知道现在iOS设备何时连接到互联网? - How do I know when the iOS device is now connected to internet? 如何知道iOS中是否连接了蓝牙设备? - How to know if a Bluetooth Device is Connected in iOS? 当应用程序在后台时,从连接的按钮 BLE 外围设备监听点击事件<react-native ble manager ios></react-native> - listen to click-event from connected button BLE peripheral, while app is in background <react-native ble manager iOS > 如何清除 iOS 中的 BLE 缓存,连接蓝牙设备 - How to clear BLE cache in iOS, connected Bluetooth device 连接BLE时在后台运行的推送通知应用 - Push Notification App Running in Background When BLE is Connected 究竟什么是iOS上的BLE连接设备? - What, exactly, is a BLE connected device on iOS? iOS应用程序在后台与设备连接 - Ios Application connected in Background with device 如何断开已连接的ble设备 - How to disconnect already connected ble device 设备未连接到系统时,IOS应用程序未收到远程通知 - IOS Application not receiving remote notification when device is not connected to System
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM