简体   繁体   中英

NSTImer in the background work only for some minutes

I have got NSTimer in my app checking in the background if it's needed to post a local notification, and it works pretty fine, but only for some minutes after entering the background mode. How can i make that NSTimer work all the time app is in the background?

[[UIApplication sharedApplication] beginBackgroundTaskWithExpirationHandler:nil];
[[NSRunLoop mainRunLoop] addTimer:self.timer forMode:NSRunLoopCommonModes];

This is only possible if you register for Long-running background tasks and needs to have a specific reason to get approval. Have a look at the documentation

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM