How can I play a sound four minutes after my app goes into background mode?
I have tried using NSTimer, but it plays after three minutes instead of four.
func applicationDidEnterBackground(application: UIApplication)
{
self.timer = NSTimer.scheduledTimerWithTimeInterval(240.0, target: self, selector: "createAVMIDIPlayer", userInfo: nil, repeats: false)
}
func createPlayer() {
if let soundURL = NSBundle.mainBundle().URLForResource("Text to Speech", withExtension: "m4a") {
var mySound: SystemSoundID = 0
AudioServicesCreateSystemSoundID(soundURL, &mySound)
AudioServicesPlaySystemSound(mySound);
}
}