I know there are many questions on SOF, but this is the \"newest\" one. The thing is, I\'m trying to create and alarm app, and I know for a fact that there are alarm apps ou
Finally, I managed to do it with NSTimer.
func applicationWillResignActive(application: UIApplication) {
var timer = NSTimer(fireDate: NSDate(timeIntervalSinceNow: 20), interval: 60.0, target: self, selector: Selector("playAlarm"), userInfo: nil, repeats: false)
NSRunLoop.currentRunLoop().addTimer(timer, forMode: NSDefaultRunLoopMode)
}
func playAlarm() {
self.sound = NSURL(fileURLWithPath: NSBundle.mainBundle().pathForResource("sound", ofType: "caf"))
self.audioPlayer = AVAudioPlayer(contentsOfURL: sound, error: nil)
audioPlayer.play()
}
and somewhere else a UILocalNotification is synced with this timer, for a good user experience.
Although I'm not sure if this would go through apple, but I don't see any reason why it wouldn't :\