2017-04-17 55 views
0

我在使用Estimote SDK在iOS 10上構建應用程序。我想使用範圍模式來檢測附近的信標。區域和信標的UUID設置正確,如在小樣本項目中驗證的那樣。RACSignal for didRangeBeacons:inRegion:無法正常工作

我現在正在構建的應用程序顯示出一些奇怪的行爲:啓動應用程序後,即使在信標旁邊也不會調用beaconManager:didRangeBeacons:inRegion:方法。

禁用/啓用藍牙將導致該方法立即觸發。對於暫停應用程序並使用調試器恢復它也是如此。

是什麼導致了這種行爲?我在每次啓動時請求許可,並等待回調開始監控(如文檔中所述)。我已經嘗試設置更多的startRanging/stopRanging調用(絕望!),但沒有成功。

任何想法?

@implementation Model {} 

    - (instancetype)init { 
     self = [super init]; 
     if (self) { 
      self.beaconManager = [ESTBeaconManager new]; 
      self.beaconManager.delegate = self; 
      self.beaconRegion = [[CLBeaconRegion alloc] 
        initWithProximityUUID:[[NSUUID alloc] 
          initWithUUIDString:proximityUUID] 
          identifier:@"Playground"]; 
      [self.beaconManager requestWhenInUseAuthorization]; 

      self.beaconSignal = [self rac_signalForSelector:@selector(beaconManager:didRangeBeacons:inRegion:) fromProtocol:@protocol(ESTBeaconManagerDelegate)]; 

      [[self.beaconSignal throttle:1] 
        subscribeNext:^(id x) { 
         NSLog(@"Did range fired"); 

        }]; 
     } 

     return self; 
    } 

    - (void)start { 
     [self.beaconManager startRangingBeaconsInRegion:self.beaconRegion]; 
    } 

    - (void)beaconManager:(id)manager didChangeAuthorizationStatus:(CLAuthorizationStatus)status { 
     if(status == kCLAuthorizationStatusAuthorizedWhenInUse){ 
      [self start]; 
     } 
    } 

回答

-1

的問題是節流訂閱RACSignalbeaconManager:didRangeBeacons:inRegion:選擇。刪除throttle或不帶信號的委託方法可以正常工作。