2

I have a question about application background refresh.

In my AppDelegate.swift, I use an NSTimer to refresh my app when my app enters background mode.

On the iOS Simulator, refresh works perfectly in background mode, but when I run my app on the real device, refresh doesn't work.

Is it impossible to use a NSTimer for refresh my app in background?

Eric Aya
  • 69,473
  • 35
  • 181
  • 253

1 Answers1

0

Your application may not stay long in the 'Background' state. It could go to 'Suspended' or be killed by the system, if it wants to. And of course, no code from your app can run in those states.

That said, I think it's not a good practice to use NSTimer for scheduling background work, and use NSNotification instead.

I recommend to read thoroughly the Energy Efficiency Guide for iOS Apps.

BPCorp
  • 780
  • 2
  • 6
  • 16