即使应用程序没有运行,如何拥有一个有效的地理围栏? [英] How to have a working Geofence even if the app is not running?

查看:81
本文介绍了即使应用程序没有运行,如何拥有一个有效的地理围栏?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在创建一个位置感知应用程序.我已经能够创建地理围栏了,当我在 iPhone 中测试它时,我注意到当应用程序在前台和后台运行时会调用回调方法 -didEnterRegion-didExitRegion.但是当我杀死应用程序时(意味着应用程序状态未运行"),没有调用所述方法回调.

I'm creating a location aware application. I was able to create geofences already, when I test it in my iPhone, I noticed that the calllback methods -didEnterRegion and -didExitRegion are being called when the application is running in foreground and background. But when I killed the application (meaning the application state is "not running") the said method call backs are not being called.

那么,我在这里错过了什么?有什么我需要做的配置吗?有没有想过的小伙伴谢谢!

So, what am I missing here? Is there any configuration that I need to do? Any thought guys? Thank you!

推荐答案

这是正确的行为,具体取决于您杀死"应用程序的方式.如果您通过从多任务视图(双击主页)向上滑动来停止应用程序,那么 iOS 7 会将其解释为您根本不希望应用程序运行 - 无论是在前台还是后台.如果应用程序在设备需要更多内存时由于处于后台而被终止",那么它将继续在后台模式下运行.

This is correct behaviour depending on how you 'killed' the app. If you stopped the app by swiping up from the multi-tasking view (double tap home) then iOS 7 interprets this as meaning you do not want the app to operate at all - either in the foreground or background. If the app is 'killed' as a result of being in the background when the device needs more memory then it will continue to operate in background mode.

参考这个答案 - ios 7 中的区域监控

为了测试您可以使用 Xcode 停止您的应用程序,在您的应用程序暂停或调用 exit() 进行测试时模拟内存不足的情况.

In order to test you can stop your application using Xcode, simulate a low-memory situation while your app is suspended or call exit() for testing purposes.

这篇关于即使应用程序没有运行,如何拥有一个有效的地理围栏?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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