Hintergrund Speicherort funktioniert nicht nach Kill/Anwendung beenden. Ich verwende in meiner Anwendung NSLocationAlwaysUsageDescription und Hintergrund holen auf auch von Fähigkeiten, hier ist mein Code:Warum Hintergrund Speicherort funktioniert nicht nach Kill/App in iOS 9.3 beenden
import UIKit
import CoreLocation
class ViewController: UIViewController, CLLocationManagerDelegate{
var locationManager: CLLocationManager!
override func viewDidLoad() {
super.viewDidLoad()
locationManager = CLLocationManager()
locationManager.delegate = self
locationManager.desiredAccuracy = kCLLocationAccuracyBest
locationManager.distanceFilter = 1000.0
locationManager.allowsBackgroundLocationUpdates = true
locationManager.startUpdatingLocation()
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
func locationManager(manager: CLLocationManager, didUpdateLocations locations: [CLLocation]) {
if(CLLocationManager.authorizationStatus() == CLAuthorizationStatus.AuthorizedWhenInUse ||
CLLocationManager.authorizationStatus() == CLAuthorizationStatus.AuthorizedAlways){
let currentLocation = manager.location
let notification = UILocalNotification()
notification.alertBody = " Lat \(currentLocation?.coordinate.latitude), Long \(currentLocation?.coordinate.longitude)"
notification.soundName = UILocalNotificationDefaultSoundName
UIApplication.sharedApplication().scheduleLocalNotification(notification)
print(" Lat \((currentLocation?.coordinate.latitude))!, Long \((currentLocation?.coordinate.longitude))!")
}
}
}
dieser Code funktioniert, wenn Klick-Taste zu Hause, aber nach Beendigung/kill App in diesem Zustand nicht funktioniert bitte geben Sie mir die Lösung hier, was ich in meinem Code verpasst habe.
Hallo Rob jetzt habe ich die Lösung und mein Code funktioniert gut, wenn app in Kill/beenden jetzt und in der Lage auch Web-Service und die Lage zu nennen. –
Aktualisierter Code funktioniert nicht im abgeschlossenen Zustand. Verwendet Xcode 8 und iOS 9.3.5 Gerät. Haben alle Codes nur in den View-Controllern geschrieben. Alles, was ich auf dem App-Delegaten schreiben muss. Bitte helfen Sie mir. – Prakash