Cardcase 应用程序可以让您知道您是否访问了之前与您有过合作关系的商店(如果您在那里设置了付款标签等)。
如果后台运行的应用程序无法在设备启动时自动启动,那么该应用程序如何工作?
编辑以使我的问题更清楚:我不是问如何监视位置更改或如何监视后台位置更改。我的问题是,如果用户安装这个应用程序,然后为某些位置添加一些选项卡,然后他们重新启动 iPhone,那么如果不支持应用程序在启动时启动,那么当他们接近某个位置时,该应用程序如何随后通知他们?
此应用程序(以及实际上任何其他应用程序)是否必须依赖于用户在每次设备重新启动后显式启动它?
最佳答案
您可以通过区域监控来做到这一点。您可以在 CLLocationManager 上使用此方法注册要监视的区域:
- (void)startMonitoringForRegion:(CLRegion *)regiondesiredAccuracy:(CLLocationAccuracy)accuracy
然后,即使您的应用程序未运行,它也会在用户进入或离开该区域时在后台启动。
来自苹果的docs :
If you begin monitoring a region and your application is subsequently terminated, the system automatically relaunches it into the background if the region boundary is crossed. In such a case, the options dictionary passed to the application:didFinishLaunchingWithOptions: method of your application delegate contains the key UIApplicationLaunchOptionsLocationKey to indicate that your application was launched because of a location-related event. In addition, creating a new location manager and assigning a delegate results in the delivery of the corresponding region messages.
编辑
刚刚用我自己的应用程序测试了这一点。在离开办公室之前重新启动了我的手机,该应用程序像往常一样在我开车回家时启动。所以是的,这绝对可以在重启后继续存在。
希望有帮助。
关于ios - 如果后台应用程序无法自动启动,Cardcase 如何在位置发生变化时启动?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8674214/