Skip to content

Instantly share code, notes, and snippets.

@gmertk
Created May 26, 2015 21:07
Show Gist options
  • Save gmertk/1252284c4a5ce10bbd58 to your computer and use it in GitHub Desktop.
Save gmertk/1252284c4a5ce10bbd58 to your computer and use it in GitHub Desktop.
When you monitor a region initialized with only UUID, didEnterRegion won't give you major and minor.
import UIKit
import CoreLocation
class ViewController: UIViewController, CLLocationManagerDelegate {
var manager = CLLocationManager()
override func viewDidLoad() {
super.viewDidLoad()
manager.delegate = self
manager.requestAlwaysAuthorization()
if let uuid = NSUUID(UUIDString: "B9407F30-F5F8-466E-AFF9-25556B57FE6D") {
let region = CLBeaconRegion(proximityUUID: uuid, identifier: uuid.UUIDString)
manager.startMonitoringForRegion(region)
}
}
// MARK: CLLocationManagerDelegate
func locationManager(manager: CLLocationManager!, didEnterRegion region: CLRegion!) {
if let region = region as? CLBeaconRegion {
// region.major and region.minor will return nil
println("Entered in region with UUID: \(region.proximityUUID) Major: \(region.major) Minor: \(region.minor)")
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment