Running js function in the background (iOS)

I have a timer function which runs using setInterval and calls itself every second to count seconds. After a certain time is does something, for example vibrates. On android, this works fine, I can switch out of the app, and go into another app, and after the time is over, it will vibrate.

In iOS this doesn’t happen at all, everything pauses until I open up the app again. I’ve tried:

  • Enabling background modes in xcode
  • Enabling the audio background mode in xcode

Thanks!

Are you sure iOS supports this? When I read this: https://developer.apple.com/library/ios/documentation/iPhone/Conceptual/iPhoneOSProgrammingGuide/BackgroundExecution/BackgroundExecution.html it isn’t one of the allowed usecases.

You’re right, but the time circle app DOES seem to run in the background.

From what I’ve read apps are allowed 180secobds of background time before they’re totally suspended.