0

I'm trying to implement background refresh in a iOS App . I need to call a class call "updatedropinanddropout" based on the location.I have added timer class while the application is in foreground it works fine, When the application goes to background it's not working. I mean I cannot call the class.

Timer.scheduledTimer(timeInterval: 4, target: self, selector: #selector(runCode), userInfo: nil, repeats: true)

I have gone through apple documentation func setMinimumBackgroundFetchInterval(_ minimumBackgroundFetchInterval: TimeInterval) I don't know how to use this function

Abdul Hoque Nuri
  • 1,105
  • 1
  • 9
  • 18
  • 4
    Timers do not run in the background. There is a background app refresh feature but you are not using it. – matt Dec 18 '18 at 06:42
  • Also your app is not running in the background, so why do you need to update anything? Update when you come back to the foreground. – matt Dec 18 '18 at 06:43
  • Possible duplicate: https://stackoverflow.com/questions/27894834/swift-how-to-use-nstimer-background – Ivan Le Hjelmeland Dec 18 '18 at 06:44
  • https://developer.apple.com/library/archive/documentation/iPhone/Conceptual/iPhoneOSProgrammingGuide/BackgroundExecution/BackgroundExecution.html – SPatel Dec 18 '18 at 06:59

0 Answers0