iPhone GPS in background never resumes after pause
If you search for pausesLocationUpdatesAutomatically
on the Apple forums you'll find a recent question along similar lines which has had a response from an Apple developer. I won't repost it directly here since it is a private forum, but the gist is that the location pausing is for instances when the user forgets that they have got a location aware app running and have stopped using it. By pausing updates their battery won't be drained as quickly. Unfortunately it's not possible to know whether new movement is them resuming the activity or doing something else, so updates don't resume until the app comes back to the foreground. Their suggestion is to catch the pause call and get the user's attention somehow to get them to open the app if they still want updates.
EDIT:
From Apple's own documentation of pausesLocationUpdatesAutomatically. They suggest:
After a pause occurs, it is your responsibility to restart location services again when you determine that they are needed. Core Location calls the
locationManagerDidPauseLocationUpdates(_:)
method of your location manager's delegate to let you know that a
pause has occurred. In that method, you might configure a local
notification whose trigger is of typeUNLocationNotificationTrigger
and is set to notify when the user exits the current region. The
message for the local notification should prompt the user to launch
your app again so that it can resume updates.
Location tracking stops after a while when app is in the background
Switch to significant location updates when the app moves to background. iOS will unload the app if it keep alive in the background indefinitely.
locationManager.pausesLocationUpdatesAutomatically = false
Why does didUpdateLocations: only have one location after locationManagerDidResumeLocationUpdates:
When you pause the location updates, the system considers that you don't need the location for now. Resuming it will only give you the current location.
This is a normal behavior.
How to keep GPS app running in background without pauses
In your info plist, add Required background modes
and set one item to App registers for location updates
Updated:
As ios return to - (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation
when there is a significant distance change. I guess you need to change:
// Set the movement threshold.
locationManager.distanceFilter = 500; // meters
Turning off GPS in background
See http://developer.apple.com/library/ios/#documentation/iphone/conceptual/iphoneosprogrammingguide/ManagingYourApplicationsFlow/ManagingYourApplicationsFlow.html
Apple does not support long running background task in general.
This does only work for specific tasks:
audio,
location,
voip,
newsstand-content,
external-accessory,
bluetooth-central and
bluetooth-peripheral
When you do not use any of that, your app could be suspended.
In your case ypu have specified location, but disabled the location update. Then for apple there is no reason to keep your app in background mode.
Related Topics
Uiview Hide/Show with Animation
Force Landscape Mode in One Viewcontroller Using Swift
How to Put an Image in a Realm Database
iOS Nsdate() Returns Incorrect Time
What Are the Device-Width CSS Viewport Sizes of the Iphone6 and iPhone 6 Plus
Uiimage Imagenamed Returns Nil
Sharing Code Between Original iOS App and App Extension
Reading the Gps Data from the Image Returned by the Camera in iOS Iphone
Converting Between Nsdata and Base64 Strings
Xcode 8 :Function Types Cannot Have Argument Label Breaking My Build
Ibeacon Notification When the App Is Not Running
Create a Rectangle with Just Two Rounded Corners in Swift
How to Implement Lazy Loading of Images in Table View Using Swift
How to Password Protect Writing to Nfc Ntag216 Tag on iOS 13 Using Nfc Core
Fix CSS Hover on Iphone/Ipad/Ipod
How to Disable Caching in Alamofire
Exc_Bad_Access When Building Nspredicate
Remove Separatorinset on iOS 8 Uitableview for Xcode 6 iPhone Simulator