OGeek|极客世界-中国程序员成长平台

标题: ios - 信标管理器 didenter didexit 区域方法被重复调用 [打印本页]

作者: 菜鸟教程小白    时间: 2022-12-12 15:41
标题: ios - 信标管理器 didenter didexit 区域方法被重复调用

我正在监控 3 个区域。 但是即使应用程序在该区域内,也确实会重复触发进入区域和 didexitregion 方法。仅当应用程序进入或退出 3 个区域中的任何一个时,我才需要通知。发生这种情况是因为我正在反复测试应用程序吗

这是我的代码:

- (BOOL)applicationUIApplication *)application didFinishLaunchingWithOptionsNSDictionary *)launchOptions {


STCloudManager setupAppID"valid is" andAppToken"valid token"];    


    UILocalNotification *locationNotification = [launchOptions objectForKey:UIApplicationLaunchOptionsLocalNotificationKey];

    if (locationNotification) {
        // Set icon badge number to zero
        application.applicationIconBadgeNumber = 0;
    }

    self.beaconManager1= [[ESTBeaconManager alloc]init];
    self.beaconManager1.delegate = self;
    self.beaconManager1.avoidUnknownStateBeacons=YES;
    self.beaconManager1.preventUnknownUpdateCount=YES;
    NSSet *set=[self.beaconManager1 monitoredRegions];
    self.region_desk=[[CLBeaconRegion alloc]
                      initWithProximityUUID:ESTIMOTE_PROXIMITY_UUID major:36798 minor:29499
                      identifier"Appdelegate_Desk_Beacon_Region"];

    self.region_door1=[[CLBeaconRegion alloc]
                       initWithProximityUUID:ESTIMOTE_PROXIMITY_UUID major:29666 minor:63757
                       identifier"Appdelegate_Door_Beacon1_Region"];

    self.region_door2=[[CLBeaconRegion alloc]

  initWithProximityUUID:ESTIMOTE_PROXIMITY_UUID major:64157 minor:33188
                       identifier"Appdelegate_Door_Beacon2_Region"];


    [self.beaconManager1 requestAlwaysAuthorization];


    //already monitoring
    if ([set count]<3) {

        if (![set containsObject:self.region_desk]) {

             [self.beaconManager1 startMonitoringForRegion: self.region_desk];
        }

        //
        if (![set containsObject:self.region_door1]) {

              [self.beaconManager1 startMonitoringForRegion: self.region_door1];
        }
        if (![set containsObject:self.region_door2]) {

            [self.beaconManager1 startMonitoringForRegion: self.region_door2];
        }




    }



    return YES;
}



Best Answer-推荐答案


你应该重启你的设备。

在 iOS 20 中,区域实例由操作系统存储。我认为它不断地将区域实例放入该操作系统区域数组中。你应该用一些随机区域填充数组,或者你应该在每次测试后重新启动你的设备。

关于ios - 信标管理器 didenter didexit 区域方法被重复调用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31162054/






欢迎光临 OGeek|极客世界-中国程序员成长平台 (http://ogeek.cn/) Powered by Discuz! X3.4