I am writing a program that takes a location in CLLocationManager on Swift and sends it to the server.
There is no problem with the operation itself, but after moving to the background, location acquisition and server information transmission will be working for a while, but server information will not be transmitted at any time.
Is there any reason such as time limit?If you know how to deal with it, I would appreciate it if you could let me know.
Attach the appropriate source.
override func viewDidLoad(){
super.viewDidLoad()
// Do any additional setup after loading the view, typically from anib.
longitude=CLLocationDegrees()
latitude=CLLocationDegrees()
keido.text=String (stringInterpolationSegment: longitude)
ido.text=String(stringInterpolationSegment:latitude)
lm = CLLocationManager()
lm.delegate=self
lm.requestAlwaysAuthorization()
lm.desiredAccuracy=kCLLocationAccuracyBest
lm.distanceFilter=5
lm.startUpdatingLocation()
}
funclocationManager(manager:CLLocationManager!, didUpdateToLocation newLocation:CLLocation!, fromLocation oldLocation:CLLocation!){
longitude = newLocation.coordinate.longitude
latitude = newLocation.coordinate.latitude
keido.text=String (stringInterpolationSegment: longitude)
ido.text=String(stringInterpolationSegment:latitude)
varmyUrl:NSURL=NSURL(string:NSSstring(format:"http://(mask)/locationget.php?id=xxxx&longitude=%@&latitude=%@", String(stringInterpolationSegment:longitude), String(stringInterpolationSegment:String)!)
varmyRequest —NSURLRequest = NSURLRequest (URL: myUrl)
NSURLConnection.sendAsynchronousRequest (myRequest,queue:NSOperationQueue.mainQueue(), completionHandler:self.getHttp)
NSLog ("Update")
}
There is a property called pauseLocationUpdatesAutomatically
, which is default and true.If this is true, it seems that the update will stop when it is judged that the location information is unlikely to change (for example, I have been staying in the same place for a while because I am eating).
CLLocationManager Class Reference
547 Who developed the "avformat-59.dll" that comes with FFmpeg?
712 When building Fast API+Uvicorn environment with PyInstaller, console=False results in an error
538 Uncaught (inpromise) Error on Electron: An object could not be cloned
548 rails db:create error: Could not find mysql2-0.5.4 in any of the sources
© 2024 OneMinuteCode. All rights reserved.