【发布时间】:2015-06-30 15:19:41
【问题描述】:
在 appDelegate 中,我有一个信标管理器和 3 个信标区域,每个区域都使用相同的 UUID 但具有不同的专业和未成年人进行初始化。我在每个信标区域上调用了 startMonitoringForRegion 方法。 问题是有时在didEnterRegion委托方法中,即使我所有的地区都有minor和major,该地区也有空的major和minor。我还为每个地区设置了不同的标识符。我必须让自己清楚,超过50%有时我在 didEnterRegion 中没有得到 nil 主要和次要,但有时它们是 nil。另外我正在使用 estimote SDK。
有人可以帮我吗?非常感谢。
这是我的代码的一小部分:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
/*
* Persmission to show Local Notification.
*/
if ([application respondsToSelector:@selector(registerUserNotificationSettings:)]) {
[application registerUserNotificationSettings:[UIUserNotificationSettings settingsForTypes:UIUserNotificationTypeAlert|UIUserNotificationTypeBadge|UIUserNotificationTypeSound categories:nil]];
}
/*
* BeaconManager setup.
*/
self.beaconManager = [[ESTBeaconManager alloc] init];
self.beaconManager.delegate = self;
self.firstBeaconRegion = [[CLBeaconRegion alloc] initWithProximityUUID:[[NSUUID alloc] initWithUUIDString:@"B9407F30-F5F8-466E-AFF9-25556B57FE6D"] major:34587 minor:56726 identifier:@"firstRegionIdentifier"];
self.secondBeaconRegion = [[CLBeaconRegion alloc] initWithProximityUUID:[[NSUUID alloc] initWithUUIDString:@"B9407F30-F5F8-466E-AFF9-25556B57FE6D"] major:23423 minor:45232 identifier:@"secondRegionIdentifier"];
self.thirdBeaconRegion = [[CLBeaconRegion alloc] initWithProximityUUID:[[NSUUID alloc] initWithUUIDString:@"B9407F30-F5F8-466E-AFF9-25556B57FE6D"] major:20106 minor:14567 identifier:@"thirdRegionIdentifier"];
self.firstBeaconRegion.notifyOnEntry = YES;
self.secondBeaconRegion.notifyOnEntry = YES;
self.thirdBeaconRegion.notifyOnEntry = YES;
[self.beaconManager startMonitoringForRegion:self.firstBeaconRegion];
[self.beaconManager startMonitoringForRegion:self.secondBeaconRegion];
[self.beaconManager startMonitoringForRegion:self.thirdBeaconRegion];
return YES;
}
- (void)beaconManager:(id)manager didEnterRegion:(CLBeaconRegion *)region
{
if (region.major != nil) {
[[RTRequestManager sharedInstance] requestBeaconWithUUID:region.proximityUUID major:region.major withCompletionBlock:^(NSArray *objects, NSError *error) {
UILocalNotification *notification = [UILocalNotification new];
notification.alertBody = [[objects firstObject] objectForKey:@"beaconLocationDetails"];
notification.soundName = UILocalNotificationDefaultSoundName;
NSString *beaconUUID =[NSString stringWithFormat:@"%@%@",[region.proximityUUID UUIDString],region.major];
RTBeaconViewController *beaconVC = [[RTBeaconViewController alloc] initWithBeacon:beaconUUID];
[_navController.topViewController presentViewController:beaconVC animated:YES completion:nil];
[[UIApplication sharedApplication] presentLocalNotificationNow:notification];
}];
}
}
【问题讨论】:
-
你能提供一些代码吗?
-
这里是整个代码。希望这对你有帮助
标签: ios