my app running in the background and I want to take the html data from the web server every 60 second. (with alamofire or nsurlconnection etc..) but I could not find sample code associated with it. Is it possible to do something like this. updated every minute I want to do.
applications running in the background mode, updateServer function I want to call every 60 second
note: with background fetch methot not working every minute. func application(application: UIApplication, performFetchWithCompletionHandler completionHandler: (UIBackgroundFetchResult) -> Void) this function not calling in background mode after 3 minutes
func updateServer() {
self.requesti = request(.POST, "http://www.myserver.com/deerer.aspx"
.response { request, response, data, error in
let dataString = NSString(data: data!, encoding:NSUTF8StringEncoding)
.......
let alis = scanned as! String
let satis = scanned as! String
self.addDataBase(alis, satis: satis)
}
}
func addDataBase(alis: String, satis: String) {
let appDelegate = UIApplication.sharedApplication().delegate as! AppDelegate
let kur = NSEntityDescription.insertNewObjectForEntityForName("Kur", inManagedObjectContext: appDelegate.managedObjectContext) as! Entity
kur.alis = alis
kur.satis = satis
kur.tarih = NSDate()
appDelegate.saveContext()
let notification = UILocalNotification()
notification.alertBody = "testtesttest"
notification.fireDate = NSDate(timeIntervalSinceNow: 1)
notification.soundName = UILocalNotificationDefaultSoundName
UIApplication.sharedApplication().scheduleLocalNotification(notification)
}