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?
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 .
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.