Geofencing didEnterRegion,didExitRegion函数没有在iphone 5S iOS8.1中调用 [英] Geofencing didEnterRegion,didExitRegion function not Calling in iphone 5S iOS8.1

查看:175
本文介绍了Geofencing didEnterRegion,didExitRegion函数没有在iphone 5S iOS8.1中调用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我整天都在调试,并且委托完全被调用。

I had debugged all day and delegate did get called at all.

- (void)locationManager:(CLLocationManager *)manager didEnterRegion:(CLRegion *)region

这里是我的标准代码,需要监视器。使用CoreLocation.framework。

Well here is my standard code calling for a monitor. use CoreLocation.framework.

[locationManager startMonitoringForRegion:geofence];

并在我的plist中注册这些。

And registered these in my plist.

<key>NSLocationAlwaysUsageDescription</key>
<string>Lugang</string>
<key>NSLocationWhenInUseUsageDescription</key>
<string>Lugang</string>

启用后台应用刷新,但我没有看到我的应用。

background app refresh in enable, but I didn't see my app within.

我曾尝试在LocationManager的实例中打印我的monitoredRegions,并且有我的受监控区域。

I had tried to print my monitoredRegions in instance of LocationManager and there is my monitored region.

NSLog(@"%@" ,locationManager.monitoredRegions);

和regionMonitoringAvailable为真。

and regionMonitoringAvailable is true.

NSLog(@"%d" , [CLLocationManager regionMonitoringAvailable] );

在iOS 8中,我曾要求requestAlwaysAuthorization

In iOS 8, I had asked for requestAlwaysAuthorization

[locationManager requestAlwaysAuthorization];

我曾尝试过三种状态,app在前台,应用程序在后台,应用程序未激活。没有这些状态被调用。

I had tried three states , app in foreground, app in background, app is not active. none of these states called.

-(void)locationManager:(CLLocationManager *)manager didFailWithError:(NSError *)error

没有任何错误。

我曾尝试过

[locationManager requestStateForRegion:geofence];

工作正常。

- (void)locationManager:(CLLocationManager *)manager didDetermineState:(CLRegionState)state forRegion:(CLRegion *)region

在我的requestStateForRegion中触发。

did trigger in my requestStateForRegion.

我不知道是什么让didEnterRegion没有被调用,我知道iOS 7及更高版本的设备可以工作,但我现在没有这样的设备可以作证。

I don't know what it is to make didEnterRegion didn't get called and I know in iOS 7 and above devices work but I don't have such a device to testify now.

也许requestStateForRegion可以满足我的要求,但我仍然无法弄清楚DidEnterRegion不起作用。并且这些都不会触发任何错误消息来告诉开发人员调试。

Maybe requestStateForRegion could fulfill my requestment, But I still couldn't figure out how does DidEnterRegion not work. And none of these trigger any error messages to tell developers to debug.

推荐答案

我遇到了同样的问题,以下是我的步骤接下来成功。

I have face same problem, Following are the steps I was follow and get succeed.


  • locationmanager 。使用下面的代码。

for (CLRegion *monitored in [locationManagerGeofence monitoredRegions])
 {
     [locationManagerGeofence stopMonitoringForRegion:monitored];
 }
 self.geofencesArray = [NSMutableArray arrayWithArray:[self buildGeofenceData]];
 if([CLLocationManager regionMonitoringAvailable])
 {
     for (CLRegion *region in self.geofencesArray)
     {
         [locationManagerGeofence startMonitoringForRegion:region desiredAccuracy:kCLLocationAccuracyBest];
     }
 }
 else
 {
     [BB_Global displayAlertWithTitle:@"" message:@"This app requires region monitoring features which are unavailable on this device."];
 }


  • 确保您的wifi已开启。

  • 使用以下代理检查您对区域的开始监控。

  • Make sure your wifi is On.
  • Check your start monitoring for region with below delegate.

    -(void)locationManager:(CLLocationManager *)manager didStartMonitoringForRegion:(CLRegion *)region
    {
        NSLog(@"Started monitoring %@ region", region.identifier);
    }
    


  • 使用这两种委托方法进行地理围栏。 1) DidEnter 2) DidExit

    这篇关于Geofencing didEnterRegion,didExitRegion函数没有在iphone 5S iOS8.1中调用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

  • 查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆