应用程序暂停时,CLLocationManager didEnterRegion:使用iBeacon [英] CLLocationManager didEnterRegion: with iBeacon while app is suspended

查看:242
本文介绍了应用程序暂停时,CLLocationManager didEnterRegion:使用iBeacon的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试唤醒我的应用程序(重新启动它),当它进入我定义的信标区域但我无法让它工作。这是我正在使用的步骤和代码。

I'm trying to wake up my app (relaunch it) when it enters my defined beacon region but I just can't get it to work. This are the steps and code I'm using.


  1. 将位置更新背景模式设置为YES。

  2. 监控我的CLBeaconRegion

  1. Set "Location updates" Background Mode to YES.
  2. Monitor my CLBeaconRegion

NSUUID *uuid = [[NSUUID alloc] initWithUUIDString:@"EBEFD083-70A2-47C8-9837-E7B5634DF524"];
    beaconRegion = [[CLBeaconRegion alloc] initWithProximityUUID:uuid identifier:@"daRegion"];
    beaconRegion.notifyEntryStateOnDisplay = NO;
    beaconRegion.notifyOnEntry = YES;
    beaconRegion.notifyOnExit = YES;
    self.locationManager = [[CLLocationManager alloc] init];
    self.locationManager.delegate = self;
    [self.locationManager startMonitoringForRegion:beaconRegion];


  • 实施委托方法

  • Implement delegate methods

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


  • 我可能遗失的任何东西?我已阅读文档,博客文章,论坛,似乎没有任何工作。 这个就是一个我读过的网站和这个是另一个。

    Anything that I might be missing? I have read the documentation, blog posts, forums and nothing seems to work. This is one of the websites I read, and this is the other.

    推荐答案

    评论当应用程序被杀时我无法让它工作至关重要。

    The comment "I just can't get it working when the app is killed" is critical.

    如果你使用iOS7应用程序切换器杀死应用程序(例如通过向上滑动应用程序图标),那么你将无法重新启动应用程序进入或离开iBeacon区域时的背景。这是设计 - 如果用户不希望应用程序运行,那么Apple认为代码不应该重新启动它。 查看此主题。

    If you use the iOS7 app switcher to kill an app (e.g. by swiping up on the app icon), then you will not be able to re-launch the app in the background upon entering or leaving an iBeacon region. This is by design -- if the user doesn't want the app running, then Apple thinks code should not be able to make it re-launch. See this thread.

    幸运的是,用户通常不这样做。出于测试目的,如果要完全停止应用程序,请不要执行此操作。重新启动手机。 (但请注意,启动后需要一分钟左右才能检测到iBeacons。)

    Fortunately, users don't typically do this. For testing purposes, if you want to completely stop an app, don't do this. Reboot your phone instead. (Note, however, that it takes a minute or so after boot before you can detect iBeacons.)

    编辑2014/03/10:此行为已更改截至iOS 7.1发布。从任务切换器中杀死应用程序不再阻止它在后台检测到iBeacons。

    这篇关于应用程序暂停时,CLLocationManager didEnterRegion:使用iBeacon的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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