I know that an iBeacon cannot broadcast/advertise in the background and I also know that its not possible for both the central and the peripheral to be in the background and discover each other. What I want to do is broadcast while in the background so that the central can discover the app while in the foreground. I'm sorry if I'm not explaining this well, please ask for clarification if I'm not clear.
I read here that "apps preform differently when running in the background as opposed to the foreground". On page 37-38 it describes what is different in the background for peripherals. It mentions "service UUIDs contained in the value of the CBAdvertisementDataServiceUUIDsKey advertisement key are placed in a special “overflow” area; they can be discovered only by an iOS device that is explicitly scanning for them." What is an overflow area and how do you explicitly search for the device? All I need is the major/minor values and the RSSI. I don't want to connect to the peripheral, I just want to interact with it as if it were an iBeacon.
Also, I need to be able to discover multiple devices (all with the same UUID) but all with unique major/minor values.
Here's my code:
var locationManager: CLLocationManager!
var beaconRegion: CLBeaconRegion!
var centralManager: CBCentralManager!
override func viewDidLoad() {
locationManager = CLLocationManager()
locationManager.delegate = self
centralManager.delegate = self
let majorVal: CLBeaconMajorValue = 123
let minorVal: CLBeaconMinorValue = 456
let uuid = NSUUID(UUIDString: "00000000-0000-0000-0000-000000000000")
beaconRegion = CLBeaconRegion(proximityUUID: uuid,identifier: "beacon")
locationManager.startRangingBeaconsInRegion(beaconRegion)
locationManager.startUpdatingLocation()
}
Then I just handle the distance to the beacon and record it's major/minor values.
This question is very similar to mine; the only difference is he wanted both devices to work in the background and I only need the peripheral to work in the background not the central.
How do I broadcast in the background and then discover in the foreground?
Thanks for your help!