iOS 应用程序无法识别我的信标.



我上周刚刚发现了iBeacon,并想试一试。我在亚马逊上买了这个信标.https://www.amazon.com/gp/product/B010Q2PUGA/ref=oh_aui_detailpage_o00_s00?ie=UTF8&psc=1使用浅蓝色应用程序, 我能够读取信标信息 (UUID, 主要, 次要, 等等) 所以我知道信标正在广播.按照本教程, 我制作了一个应用程序来熟悉信标编程.(使用我的UUID)代码有一个小改动,由于快速版本,我不得不将println更改为打印。https://willd.me/posts/getting-started-with-ibeacon-a-swift-tutorial有了这一切, 我的应用程序似乎无法识别我的信标.在我的日志/调试区域中,我只看到:

[]
[]
[]

我的代码是:

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:版本 7.3.1 (7D1014)

OS X El Capitan: 版本 10.11.5 (15F34)

iOS: 版本 9.3.2(13F69)

Apple Swift 版本 2.2 (swiftlang-703.0.18.8 clang-703.0.31)

我怀疑 8EBB5704-9697-02C9-D073-BF9162B72D7B 不是信标的邻近 UUID. LightBlue将显示蓝牙设备的许多不同的UUID,并非所有UUID都是邻近UUID。 像任何iOS应用程序一样,LightBlue必须知道PriximityUUID才能使用CoreLocation检测信标。 如果没有, 它仍然可以检测蓝牙传输与核心蓝牙, 但它将无法读取iBeacon标识符. 这可能就是正在发生的事情。

您需要找出设备的邻近 UUID。 如果您无法使用制造商说明执行此操作, 您可以使用带有定位应用程序的Android设备, 它可以读取iBeacon UUID,而无需预先知道标识符. iOS 设备无法执行此操作。

最新更新