title: Confusion about BLE beacon usage in iOS - how to get the correct identifier?
body: <p>I have been trying to play around with BLE beacons for a while now and have run into some confusing problems.</p>
  
  <p>What I want to achieve:</p>
  
  <ol>
  <li>Scan for near by beacons</li>
  <li>Select beacons to save</li>
  <li>Monitor when selected beacons are in/out of range.</li>
  </ol>
  
  <p>Here is the code I use to scan for nearby beacons:</p>
  
  <pre><code>public func centralManager(_ central: CBCentralManager, didDiscover peripheral: CBPeripheral, advertisementData: [String : Any], rssi RSSI: NSNumber) {
      if(peripheral.name != nil &amp;&amp; peripheral.name!.contains("MkiBeacon")){
          print("\n Beacon   : \(String(describing: peripheral.name)) \(peripheral.identifier)
              \(peripheral.major):\(peripheral.minor)
              \(peripheral.beaconName) \(peripheral.beaconUUID) \(peripheral.deviceID) ")
      }
  }
  </code></pre>
  
  <p>Here I get only peripheral <code>name</code> and <code>identifier</code> all other values like <code>major,minor,UUID</code> are undefined.</p>
  
  <p>After that I try using <code>identifier</code> to monitor beacon region events:</p>
  
  <pre><code>        locationManager = CLLocationManager()
          locationManager?.delegate = self
          locationManager?.requestAlwaysAuthorization()
          let uuid = UUID(uuidString: peripheral.identifier)
          let major:CLBeaconMajorValue = 0
          let minor:CLBeaconMinorValue = 491
          let identifier = "myBeacon"
          let region = CLBeaconRegion(proximityUUID: uuid!, major:major,minor:minor,identifier: identifier)
          region.notifyOnEntry = true
          region.notifyEntryStateOnDisplay = true
          region.notifyOnExit = true
          locationManager?.startRangingBeacons(in: region)
          locationManager?.startMonitoring(for: region)
  </code></pre>
  
  <p>It seems that <code>peripheral.identifier</code> isn't the correct value it needs, as it doesn't work. It works when I ender the UUID from another beacon scanning app I use to check my beacons.</p>