gpt4 book ai didi

ios - didEnterRegion 信标管理器方法返回一个没有主要和次要的区域

转载 作者:行者123 更新时间:2023-11-29 12:19:11 34 4
gpt4 key购买 nike

在 appDelegate 中,我有一个信标管理器和 3 个信标区域,每个区域都使用相同的 UUID 初始化,但具有不同的主次区域。我在每个信标区域上调用了 startMonitoringForRegion 方法。问题是有时在didEnterRegion委托(delegate)方法中,即使我所有的区域都有未成年人和专业,该区域也有null major和minor。我还为每个区域设置了不同的标识符。我必须清楚,在50%以上有时我在 didEnterRegion 中没有得到 nil major 和 minor,但有时它们是 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];
}];

}
}

最佳答案

试试这个:-

         NSSet *set=[self.beaconManager1 monitoredRegions];                
if ([set count]<3)
{
[self.beaconManager startMonitoringForRegion: [[CLBeaconRegion alloc] initWithProximityUUID:ESTIMOTE_PROXIMITY_UUID major:anyvalue minor:anyyour value identifier:@"your identifier"]];
}

每次进入,退出甚至发生这些 didlaunchwithoption 将被调用并一次又一次地监视同一个区域,即使这些区域将在您下次调用 startmonitoring 时替换。但我已经看到一些与此相关的问题,所以你必须检查它是否已经在监控,因为你只想监控这些区域一次。重启设备后再试

关于ios - didEnterRegion 信标管理器方法返回一个没有主要和次要的区域,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31142258/

34 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com