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
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.