在info.plist中:
我们增加了NSLocationAlwaysUsageDescription。在required background modes上,我们添加了所有蓝牙设备(与蓝牙通信和共享数据)和位置- "register for location updates"。
我们引进了location and bluetooth frameworks和基金会。
我们从以下几个方面开始蓝牙:
  if([self.locationManager respondsToSelector:@selector(requestAlwaysAuthorization)])
    {
        [self.locationManager requestAlwaysAuthorization];
     }
    self.locationManager = [[CLLocationManager alloc] init];
    self.locationManager.delegate = self;
    self.beaconRegion.notifyOnEntry=YES;
    self.beaconRegion.notifyOnExit=YES;
    self.beaconRegion.notifyEntryStateOnDisplay=YES;
    [self.locationManager requestAlwaysAuthorization ];
    [self.locationManager requestWhenInUseAuthorization];
    NSUUID *uuid_in = [[NSUUID alloc] initWithUUIDString:uuid];
    self.beaconRegion = [[CLBeaconRegion alloc] initWithProximityUUID:uuid_in identifier:@"com.name.us"];
    [self.locationManager startMonitoringForRegion:self.beaconRegion];委托称为:
- (void)locationManager:(CLLocationManager *)manager didStartMonitoringForRegion:(CLRegion *)region {
    NSLog(@"started:%@",region);
    //[self.locationManager requestStateForRegion:self.beaconRegion];
    self.beaconRegion.notifyEntryStateOnDisplay=YES;
}问题是,当我们打开硬件信标(它正在与其他应用程序一起工作)时,委托并不被称为 (iPhone6):
- (void)locationManager:(CLLocationManager *)manager didEnterRegion:(CLRegion *)region {
-(void)locationManager:(CLLocationManager *)manager didExitRegion:(CLRegion *)region {
-(void)locationManager:(CLLocationManager *)manager didRangeBeacons:(NSArray *)beacons inRegion:(CLBeaconRegion *)region {发布于 2015-05-19 13:23:02
以下是一些小窍门:
CLBeaconRegion之前,您正在修改它。以self.beaconRegion.notifyOnEntry=YES;开头的行需要向下移动,以便在初始化后进行。uuid_in实际上与您的信标匹配。请张贴这是如何初始化的代码,以便我们可以帮助确定。https://stackoverflow.com/questions/30326106
复制相似问题