2

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!

Adam Eberbach
  • 12,309
  • 6
  • 62
  • 114
  • I'm asking if there could be work-arounds that the application will be able to notify the user even if the application is not running. Because Foursquare is able to do this in iOS7. Thanks ... – Josh Byanec McFergan Mar 17 '14 at 05:13
  • I don't know how Foursquare does it, but see https://devforums.apple.com/message/906456#906456 - Apple guy pmarcos confirms this no longer works in iOS7. (this is also linked from the duplicate question's answers) – Adam Eberbach Mar 17 '14 at 05:18
  • You are tagging it as a duplicate, but my question is to clarify further if there's a way (meaning work-around) on making a working Geofence when Applciation is terminated because if Foursquare can do it, why can't we? Right? – Josh Byanec McFergan Mar 18 '14 at 05:54

1 Answers1

3

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.

Community
  • 1
  • 1
Paulw11
  • 108,386
  • 14
  • 159
  • 186
  • So you mean, that there's is no way I can get any notification when the application is terminated? But my client requirement needs it to notify via Local Notification when the user detects that its location entered a certain region... Can you help? Thanks – Josh Byanec McFergan Mar 17 '14 at 05:11
  • According to this thread https://devforums.apple.com/thread/209302?tstart=0 on the Apple Developer forums this is changed behaviour in iOS 7. You should receive background notifications if your app is merely suspended but not if it is terminated. – Paulw11 Mar 17 '14 at 05:24
  • Have you enabled significant location change notification? Also, I am still not clear on how you are terminating the app? Is it by swiping up from the App Switcher? – Paulw11 Mar 17 '14 at 05:59
  • Yup, I'm swiping up from the App Switcher. This is kind a weird, because, Foursquare is able to do it. i'm receiving notification even if my app is not running... – Josh Byanec McFergan Mar 18 '14 at 03:23
  • But have you actually 'killed' Foursquare via swipe-up or have you just not started it - there is a difference – Paulw11 Mar 18 '14 at 03:45
  • The same thing that I'm doing when I terminate my Application, which is swipe-up. – Josh Byanec McFergan Mar 18 '14 at 04:11
  • Hmmm. I wonder if Foursquare are sending push notifications to wake their app? That might relaunch it, but that is just a guess. Also, do you have significant location change notification enabled? – Paulw11 Mar 18 '14 at 04:21
  • I'm putting my code in DidUpdateLocation. Actually,what I wanted right now is just to make the application wake up when it enters a geofence. Cause of foursquare can do it, why can't we? right? Thanks for your help. Greatly Appreciated... – Josh Byanec McFergan Mar 18 '14 at 05:51
  • There are indications that the background behaviour has changed once again in 7.1 and that apps in a killed state will once more receive location notifications - https://devforums.apple.com/thread/221825?tstart=0 – Paulw11 Mar 20 '14 at 08:03