- I'm still studying. incomplete sample~
I created a sample that can get gps information in the background with swift.
How do you make GPS available in the background for a long time? Suggest a way.
...
later ... Oh, my God.. ! Then I did not take the coordinates. Later .... I have to ... I've done it for over 10 minutes in the background ... This is a sample. Download and run it.
- How to test?
- Run the project.
- Click the Start button.
- Create the app in the background.
- Disable your mobile phone by pressing the power button.
- Wait at least 10 minutes.
- Continue logging well.
- So it is success.
- ViewController.swift
/// Go to settings app
@IBAction func onSettingApp(_ sender: Any) {
guard let settingsUrl = URL(string: UIApplicationOpenSettingsURLString) else {
return ()
}
if UIApplication.shared.canOpenURL(settingsUrl) {
UIApplication.shared.open(settingsUrl, completionHandler: { (_) in
})
}
}