why is my didEnterRegion delegate not called?

2019-03-02 07:23发布

I am developing an app that checks for Beacons but I am having issues that my delegate is never run when I enter a region, I know the beacon is ok and broadcasting because I can see it in other beacon apps like "locate beacon"

I have configured the same UUID in the transmitter and the receiver app and I have double verified them so I am sure they are the same, below is my code that starts the locationManager and monitors for the region including the delegate.

Debugs tells me the monitoring is started correctly as per below

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

Below is the class definition that includes the delegate

@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];
}

Why is my delegate never called?

0条回答
登录 后发表回答