How is everyone doing with iBeacons on iOS 10.0.2? Hopefully better than me !:-)
Update. The equipment used for testing is two iPhones. IPhone 5S (A1533) and iPhone 7 (A1778)
The quick version 2.x of the code below can be used on iPhone to advertise a simple iBeacon on iOS versions 9.x; Today, the same code updated for fast version 3 and running on iOS 10.0.2 is not published at all.
I have reduced the code to a very simple helper class and a viewcontroller, which I think should adequately demonstrate the problem. Please note that there is only one button in the storyboard related to starting / stopping iBeacon ads.
I launched the application on iPhone 5 and iPhone 7 with iOS 10.0.2. For testing, I created my own scanner (sniffing for a specific proximity UUID), and when this did not work, I tried the more general iBeacon to detect applications such as Estimote and LightBlue.
Sigh - nothing sees iBeacon.
Thoughts? Apple's developer forums mention issues reported by iBeacons in 10.x, but nothing is as simple as that, as far as I can tell.
Thanks a lot ...
- - - iBeaconConfiguration.swift - - - - - - import Foundation class iBeaconConfiguration { static let uuid = UUID(uuidString: "F34A1A1F-500F-48FB-AFAA-9584D641D7B1")! private init() {} } - - - ViewController.swift - - - - - - import UIKit import CoreLocation import CoreBluetooth class ViewController: UIViewController, CBPeripheralManagerDelegate { @IBOutlet weak var btnAction: UIButton! let UUID: UUID = iBeaconConfiguration.uuid var beaconRegion: CLBeaconRegion! var dataDictionary = NSDictionary() var bluetoothPeripheralManager: CBPeripheralManager! var isBroadcasting = false override func viewDidLoad() { super.viewDidLoad() bluetoothPeripheralManager = CBPeripheralManager(delegate: self, queue: nil, options: nil) } @IBAction func switchBroadcastingState(_ sender: AnyObject) { if !isBroadcasting { if bluetoothPeripheralManager.state == CBManagerState.poweredOn { let major: CLBeaconMajorValue = 123 let minor: CLBeaconMinorValue = 456 beaconRegion = CLBeaconRegion(proximityUUID: UUID, major: major, minor: minor, identifier: "com.rdz.bcast") dataDictionary = beaconRegion.peripheralData(withMeasuredPower: nil) bluetoothPeripheralManager.startAdvertising(dataDictionary as? [String : Any]) btnAction.setTitle("Stop", for: UIControlState.normal) isBroadcasting = true } } else { bluetoothPeripheralManager.stopAdvertising() btnAction.setTitle("Start", for: UIControlState.normal) isBroadcasting = false } } func peripheralManagerDidStartAdvertising(_ peripheral: CBPeripheralManager, error: Error?) { print ("peripheralManagerDidStartAdvertising()") if error != nil { print(error) } } func peripheralManager(_ peripheral: CBPeripheralManager, didReceiveRead request: CBATTRequest) { print ("peripheralManager(...didReceiveRead)") } func peripheralManagerDidUpdateState(_ peripheral: CBPeripheralManager) { var statusMessage = "" switch peripheral.state { case CBManagerState.poweredOn: statusMessage = "Bluetooth Status: Turned On" case CBManagerState.poweredOff: if isBroadcasting { switchBroadcastingState(self) } statusMessage = "Bluetooth Status: Turned Off" case CBManagerState.resetting: statusMessage = "Bluetooth Status: Resetting" case CBManagerState.unauthorized: statusMessage = "Bluetooth Status: Not Authorized" case CBManagerState.unsupported: statusMessage = "Bluetooth Status: Not Supported" default: statusMessage = "Bluetooth Status: Unknown" } print("Bluetooth Status: \(statusMessage)") } } - - - END - - - - -
(Sorry for the errors of any code format.)