1

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)

MWW
  • 13
  • 4

1 Answers1

1

I suspect that 8EBB5704-9697-02C9-D073-BF9162B72D7B is not the Proximity UUID of the beacon. LightBlue will show a number of different UUIDs for a Bluetooth device, not all of them are the ProximityUUID. Like any iOS app, LightBlue must know the PriximityUUID to detect beacons with CoreLocation. If it does not, it can still detect Bluetooth transmissions with CoreBluetooth, but it will be unable to read the iBeacon identifiers. This is probably what is happening.

You need to find out the ProximityUUID for the device. If you cannot do so with the manufacturer instructions, you could use an Android device with the Locate app, which can read iBeacon UUIDs without knowing the identifiers up front. An iOS device cannot do this.

davidgyoung
  • 63,876
  • 14
  • 121
  • 204
  • Thanks for the reply. Unfortunately, the unit came with absolutely no documentation, and I don't have an android device .... – MWW Jul 10 '16 at 23:44
  • Well, I was able to find a Windows app that gave me a different UUID as well as the integer value of Major and Minor. All is working now! Thanks for the info. – MWW Jul 11 '16 at 03:20