0
私のアプリの皆さん、ここでiBeaconsを探していますが、didExitRegionメソッドは私がRegionから出るときに呼び出されますが、領域に入るとdidEnterRegionメソッドは呼び出されません。私はここに didEnterRegionは呼び出されませんでしたが、exitExitRegionが目的地Cで呼び出されました
のInfo.plist
に常にバックグラウンドの更新、リモート通知、ロケーション要求を固定することは、私のコード- (void)viewDidLoad
{
[super viewDidLoad];
locManager=[[CLLocationManager alloc] init];
locManager.delegate=self;
[self initRegion];
if([locManager respondsToSelector:@selector(requestAlwaysAuthorization)])
{
[locManager requestAlwaysAuthorization];
}
// clBeconRegion.notifyOnEntry=YES;
clBeconRegion.notifyEntryStateOnDisplay=YES;
}
-(void)initRegion
{
NSUUID *uuid=[[NSUUID alloc]initWithUUIDString:UUID];
clBeconRegion=[[CLBeaconRegion alloc]initWithProximityUUID:uuid identifier:@"BeaconExample"];
// clBeconRegion=[[CLBeaconRegion alloc]initWithProximityUUID:uuid major:8983 minor:738
// identifier:@"aB"];
// clBeconRegion=[[CLBeaconRegion alloc]initWithProximityUUID:uuid major:8983 minor:728
// identifier:@"bB"];
clBeconRegion.notifyOnEntry=YES;
// clBeconRegion.notifyOnExit=YES;
clBeconRegion.notifyEntryStateOnDisplay=YES;
[locManager startMonitoringForRegion:clBeconRegion];
}
-(void)locationManager:(CLLocationManager *)manager didStartMonitoringForRegion:(CLRegion *)region{
NSLog(@"didStartMonitoringFor Region");
// [locManager startRangingBeaconsInRegion:clBeconRegion];
[locManager requestStateForRegion:clBeconRegion];
}
-(void)locationManager:(CLLocationManager *)manager didDetermineState:(CLRegionState)state forRegion:(CLRegion *)region{
switch (state) {
case CLRegionStateInside:
[locManager startRangingBeaconsInRegion:clBeconRegion];
NSLog(@"Region Inside");
break;
case CLRegionStateOutside:
// [locManager stopRangingBeaconsInRegion:clBeconRegion];
NSLog(@"Region OutSide %ld",(long)state);
case CLRegionStateUnknown:
default:
// stop ranging beacons, etc
NSLog(@"Region unknown %ld",(long)state);
}
}
-(void)locationManage:(CLLocationManager *)manager didEnterRegion:(CLRegion *)region{
NSLog(@"Entered Region");
[locManager startRangingBeaconsInRegion:clBeconRegion];
CLBeaconRegion *reg=(CLBeaconRegion *)region;
[disObj login:[NSString stringWithFormat:@"%@", reg.major] :[NSString stringWithFormat:@"%@", reg.minor]];
NSString *enterRegion=[NSString stringWithFormat:@"You ENTERED a Region %@",reg.minor];
[self sendLocalNotificationWithMessage1:enterRegion];
}
-(void)locationManager:(CLLocationManager *)manager didExitRegion:(CLRegion *)region{
CLBeaconRegion *reg=(CLBeaconRegion *)region;
NSString *exit=[NSString stringWithFormat:@"You Exit a Region %@",reg.minor];
[self sendLocalNotificationWithMessage1:exit];
NSLog(@"Exit Region");
[locManager stopRangingBeaconsInRegion:clBeconRegion];
}
-(void)locationManager:(CLLocationManager *)manager didRangeBeacons:(NSArray *)beacons inRegion:(CLBeaconRegion *)region{}
を明確にするためではないlocationManageを書いて、あなたはあなたを言っていますget * mu ltipleは* didExitRegionを呼び出します(ビーコンを再びオン/オフする場合)。しかし、didEnterRegionの呼び出しは一度もありません。 – davidgyoung
はい一度地域を終了すると、didExitRegionが複数呼び出されますが、didEnterRegionは呼び出されません –