为什么我的didEnterRegion委托没有被调用?

时间:2017-05-04 10:48:27

标签: ios cllocationmanager ibeacon

我正在开发一个检查Beacons的应用程序,但我遇到的问题是我的代表在我进入某个区域时从未运行过,我知道信标可以播放,因为我可以在其他信标应用中看到它,例如“找到信标“

我在发送器和接收器应用程序中配置了相同的UUID,我对它们进行了双重验证,所以我确信它们是相同的,下面是我的代码,它启动了locationManager并监视包括代理在内的区域。

调试告诉我,监控按照以下正确启动

SelfCheckout[2977:845403] location Manager started to monitor regions: {(
CLBeaconRegion (identifier:'me.netwizards.office', uuid:39876A4B-43B2-4BE8-9A9C-41BAE913D56A, major:(null), minor:(null))
)}

以下是包含代理

的类定义
@interface ViewController : UIViewController <CLLocationManagerDelegate>

-

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.

    // Initialize location manager and set ourselves as the delegate
    self.locationManager = [[CLLocationManager alloc] init];
    self.locationManager.delegate = self;

    [self.locationManager requestWhenInUseAuthorization];

    // Create a NSUUID with the same UUID as the broadcasting beacon
    NSUUID *uuid = [[NSUUID alloc] initWithUUIDString:@"39876A4B-43B2-4BE8-9A9C-41BAE913D56A"];

    // Setup a new region with that UUID and same identifier as the broadcasting beacon
    self.myBeaconRegion = [[CLBeaconRegion alloc] initWithProximityUUID:uuid
                                                             identifier:@"me.netwizards.office"];

    // Tell location manager to start monitoring for the beacon region
    [self.locationManager startMonitoringForRegion:self.myBeaconRegion];
    NSLog(@"location Manager started to monitor");
}

- (void)locationManager:(CLLocationManager*)manager didEnterRegion:(CLRegion*)region
{
    NSLog(@"Did Enter Region");
    [self.locationManager startRangingBeaconsInRegion:self.myBeaconRegion];
}

为什么我的代表从未打过电话?

0 个答案:

没有答案