Making ios7 BLE peripheral to work in background

前端 未结 1 1643
猫巷女王i
猫巷女王i 2021-02-06 19:04

I have read every related information about it, but still can\'t make my iOS7 device work like peripheral advertiser in background. It works fine in foreground, but in backgroun

相关标签:
1条回答
  • 2021-02-06 20:04

    Note this line from the startAdvertising: method's documentation:

    While an application is in the background, the local name will not be used and all service UUIDs will be placed in the "overflow" area. However, applications that have not specified the "bluetooth-peripheral" background mode will not be able to advertise anything while in the background.

    That is, the backgrounded peripheral removes every thing from the advertisement and only its presence can be detected by non iOS applications. iOS apps are able to reach the overflow area but MacOS apps can't. You need to turn off the service filtering on the MacOS side to be able to detect the peripheral and connect to it to discover if it has the searched service.

    FYI, there is no workaround for this scenario, it has been discussed several times on the Apple bluetooth-dev mailing list and in many SO questions.

    Also note that CBAdvertisementDataOverflowServiceUUIDsKey is not a valid input key for startAdvertising:. CBAdvertisementDataOverflowServiceUUIDsKey is returned by iOS in the didDiscoverPeripheral callback if it found something in the overflow area. Use only CBAdvertisementDataServiceUUIDsKey to define the list of advertised services.

    0 讨论(0)
提交回复
热议问题