1

I searched a lot for one week. I searched google for the same question and I was able to get something working. But location updates don't work for the suspended state. It only works for foreground and background states.

And I need location updates after terminated state also.

Hubert Kunnemeyer
  • 2,261
  • 1
  • 15
  • 14
Rojarao
  • 11
  • 3
  • 2
    Please read [ask] and take the [tour]. You should update accordingly. You have to show some efforts. What have you tried, some code, etc. – tupui Aug 10 '17 at 11:29
  • You can get "The significant location change service", Check this answer "https://stackoverflow.com/questions/37450524/ios-getting-location-updates-when-app-terminated-without-using-significantchange" Or read this... https://developer.apple.com/documentation/corelocation/cllocationmanager#//apple_ref/doc/uid/TP40007125-CH3-SW73 – Ratnesh Shukla Aug 10 '17 at 11:33

1 Answers1

0

Please refer to applicationWillTerminate

By Apple documentation it says:

This method lets your app know that it is about to be terminated and purged from memory entirely. You should use this method to perform any final clean-up tasks for your app, such as freeing shared resources, saving user data, and invalidating timers. Your implementation of this method has approximately five seconds to perform any tasks and return. If the method does not return before time expires, the system may kill the process altogether. For apps that do not support background execution or are linked against iOS 3.x or earlier, this method is always called when the user quits the app. For apps that support background execution, this method is generally not called when the user quits the app because the app simply moves to the background in that case. However, this method may be called in situations where the app is running in the background (not suspended) and the system needs to terminate it for some reason. After calling this method, the app also posts a UIApplicationWillTerminate notification to give interested objects a chance to respond to the transition.

If you want to have user's location when app is not in memory, short answer: Impossible.

Stefan
  • 1,283
  • 15
  • 33
  • Still , i did not get any location updates while iphone terminated? any one have code Please send me? – Rojarao Aug 19 '17 at 07:25
  • locationManager.allowsBackgroundLocationUpdates = true locationManager.pausesLocationUpdatesAutomatically = false locationManager.startMonitoringSignificantLocationChanges() You also have to set certain keys in the plist file and request authorization etc. – ScottyBlades Apr 13 '19 at 22:06