问题
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!
回答1:
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.
Refer to this answer - Region monitoring in ios 7
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.
来源:https://stackoverflow.com/questions/22447050/how-to-have-a-working-geofence-even-if-the-app-is-not-running