I am developing an iOS application which works both in background and foreground. Everything works fine when the application is in foreground state but whenever the application is in background state and central manager is scanning for peripherals with custom UUID it doesn't call the didDiscoverPeripheral
method and as soon as my application comes in foreground peripheral gets discovered.
Shared.sharedInstance.centralManager?.scanForPeripherals(withServices: [serviceUUID], options:[CBCentralManagerScanOptionAllowDuplicatesKey:true])
I am scanning with service UUID as described in apple's documentation to scan for peripherals in background. Enable Bluetooth specific keys inside "Project -> Target -> Capabilities".
Application is registered to work in background.
Getting service UUID inside scan response from device as follows :-
▿ 3 elements
▿ 0 : 2 elements
- .0 : "kCBAdvDataIsConnectable"
- .1 : 1
▿ 1 : 2 elements
- .0 : "kCBAdvDataServiceUUIDs"
▿ .1 : 1 element
- 0 : 6E02
▿ 2 : 2 elements
- .0 : "kCBAdvDataLocalName"
- .1 : Local Name
Any help would be appreciated.