Last active
February 25, 2019 16:05
-
-
Save vnsam/7d7c9f152549560c53e0b2530b2fc98f to your computer and use it in GitHub Desktop.
Timer - App background support
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
extension Timer { | |
static func scheduleTimerEnablingBackground(timeInterval: TimeInterval, target: Any, | |
selector: Selector, userInfo: Any?, | |
repeats: Bool) -> Timer { | |
// Enable background expiration | |
UIApplication.shared.beginBackgroundTask(expirationHandler: nil) | |
let timer = Timer.scheduledTimer(timeInterval: timeInterval, | |
target: target, | |
selector:selector, | |
userInfo: userInfo, | |
repeats: repeats) | |
return timer | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment