I just found out about iBeacon last week and thought I'd give it a go. I bought this beacon on Amazon. https://www.amazon.com/gp/product/B010Q2PUGA/ref=oh_aui_detailpage_o00_s00?ie=UTF8&psc=1 Using the Light Blue app, I am able to read the beacon info (UUID, Major, Minor, etc.) so I know the beacon is broadcasting. Following this tutorial, I made an app to get familiar with programming for beacons. (Using my UUID) There is one minor change to the code, I had to change println to print due to swift versions. https://willd.me/posts/getting-started-with-ibeacon-a-swift-tutorial With all that, my app does not seem to recognize my beacon. In my log/debug area I see only:
[]
[]
[]
My code is:
import UIKit
import CoreLocation
class ViewController: UIViewController, CLLocationManagerDelegate {
let locationManager = CLLocationManager()
let region = CLBeaconRegion(proximityUUID: NSUUID(UUIDString: "8EBB5704-9697-02C9-D073-BF9162B72D7B")!, identifier: "iBeacon-6713")
// let region = CLBeaconRegion(proximityUUID: NSUUID(UUIDString: "8EBB5704-9697-02C9-D073-BF9162B72D7B")!, major: 11046, minor: 11047, identifier: "ibeacon")
override func viewDidLoad() {
super.viewDidLoad()
locationManager.delegate = self;
if (CLLocationManager.authorizationStatus() != CLAuthorizationStatus.AuthorizedWhenInUse) {
locationManager.requestWhenInUseAuthorization()
}
locationManager.startRangingBeaconsInRegion(region)
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
// func locationManager(manager: CLLocationManager, didRangeBeacons beacons: [CLBeacon], inRegion region: CLBeaconRegion) {
// print(beacons)
// }
func locationManager(manager: CLLocationManager, didRangeBeacons beacons: [CLBeacon], inRegion region: CLBeaconRegion) {
print(beacons)
}
}
xcode: Version 7.3.1 (7D1014)
OS X El Capitan: Version 10.11.5 (15F34)
iOS: Version 9.3.2(13F69)
Apple Swift version 2.2 (swiftlang-703.0.18.8 clang-703.0.31)