위해 죽일 applicationWillTerminate에서 사용하기에도 응용 프로그램은 지금까지 지금까지서버 (웹 파일)에 대한 사용자의 위치를 보내기도 응용 프로그램이 종료되거나 종료 또는 내가 백그라운드에서 서버 파일을 5 분마다 사용자의 현재 위치를 전송하려면 아이폰 OS 스위프트
var timer = Timer()
func applicationDidEnterBackground(_ application: UIApplication) {
timer.invalidate() // just in case this button is tapped multiple times
timer = Timer.scheduledTimer(timeInterval: 0.5, target: self, selector: #selector(timerAction), userInfo: nil, repeats: true)
}
func timerAction() {
//call the location manger to update the location to the server
}
func applicationWillTerminate(_ application: UIApplication) {
//need code to call continuously even app closed
}
당신은 이것을 할 수 없을 것입니다. 사람들의 위치를 추적 할 수는 없습니다. –
앱을 항상 백그라운드에서 실행하는 옵션이 있습니까? 사용자가 앱을 닫지 못하게하거나 앱을 닫을 경우 앱이 백그라운드에서 실행되는 것을 허용하지 않습니다. –