2014-11-23 30 views
0

我正在從硬件iBeacon獲取數據,我可以在其中編程以更改其UUID。iBeacon標識符值 - 爲什麼它不起作用?

我知道硬件的UUID,但我不明白什麼是標識符:

[[CLBeaconRegion alloc] initWithProximityUUID:uuid identifier:@"com.name.iBeacon"]; 

它是我的應用程序標識符,或東西iBeacon顯示正在發送(它的名字嗎?) 不知這就是爲什麼它不起作用。 我已經設置好一切,我甚至不能發現iBeacon顯示:

self.locationManager = [[CLLocationManager alloc] init]; 
    self.locationManager.delegate = self; 

    NSUUID *uuid = [[NSUUID alloc] initWithUUIDString:@"74278BDA-B644-4520-8F0C-720EAF059935"]; 
    self.beaconRegion = [[CLBeaconRegion alloc] initWithProximityUUID:uuid identifier:@"com.company.iBeacon"]; 
    [self.locationManager startMonitoringForRegion:self.beaconRegion]; 
     [self locationManager:self.locationManager didStartMonitoringForRegion:self.beaconRegion]; 

比這些代表,這是在同一個班(?應該是在應用程序委託)從未被觸發:

- (void)locationManager:(CLLocationManager *)manager didEnterRegion:(CLRegion *)region { 
    [self.locationManager startRangingBeaconsInRegion:self.beaconRegion]; 
    NSLog(@"ENTER"); 

} 

-(void)locationManager:(CLLocationManager *)manager didExitRegion:(CLRegion *)region { 
    [self.locationManager stopRangingBeaconsInRegion:self.beaconRegion]; 
    NSLog(@"EXIT"); 
} 

我讀過,你必須進出該區域?

另一個問題是,蘋果公司表示,每個BLE都有服務,包括特性,但是在iBeacon中,主要和次要的價值是什麼?同一項服務的特點?

+0

標識符是您想要的任何字符串。您可以使用它來區分委託方法中的不同信標區域。至於爲什麼你的代表沒有被調用,如果你正在運行ios8,你需要在使用時請求或始終授權位置管理器 – Paulw11 2014-11-23 12:49:35

+0

主要和次要值只是進一步識別您的區域的方法。主要可能是地板,未成年人可能表示該部門 - 這取決於你。 iBeacon與BLE設備不同 - 它不會廣告任何服務或特性 – Paulw11 2014-11-23 12:51:26

+0

順便說一句,您錯了,iBeacon會廣告服務和特性,如果您將編寫BLE代碼,您會發現它以及它的服務。服務和特性是協議的一部分BLE – Curnelious 2014-11-23 13:17:55

回答

0

明白了,

if([self.locationManager respondsToSelector:@selector(requestAlwaysAuthorization)]) { 
     [self.locationManager requestAlwaysAuthorization]; 
    } 

必須首先完成。

相關問題