Reputation: 1
My app act as a beacon but I want to add its local name like my appName. I want to know that can we advertise custom packet in which I can add local name while advertising major, minior, proximityuuid, and identifier in Swift.
My current code for advertiseing ibeacon:
func initLocalBeacon() {
if localBeacon != nil {
stopLocalBeacon()
}
let uuid = UUID(uuidString: localBeaconUUID)!
localBeacon = CLBeaconRegion(uuid: uuid, major: localBeaconMajor, minor: localBeaconMinor, identifier: identifier)
beaconPeripheralData = localBeacon.peripheralData(withMeasuredPower: nil)
peripheralManager = CBPeripheralManager(delegate: self, queue: nil, options: nil)
}
func peripheralManagerDidUpdateState(_ peripheral: CBPeripheralManager) {
if peripheral.state == .poweredOn {
peripheralManager.startAdvertising(beaconPeripheralData as? [String: Any])
}
else if peripheral.state == .poweredOff {
peripheralManager.stopAdvertising()
}
}
I am trying to add custom packet in which I add local name for my beacon. Is it possible?
Upvotes: 0
Views: 102
Reputation: 64941
Yor app has very limited control over BLE advertisements on iOS because it is a shared resource across all apps.
Here’s what an app can do:
Here is what the phone (not your app) can do:
Your app cannot change the advertised name in the scan response. It cannot advertise additional data over BLE other than shown above, giving you a limited number of bytes to work with.
Upvotes: 0