Which technology to use to set the alarm at Swift for iOS
<p>I do alarm clock app. That is my view:</p>

<p><a href="https://i.stack.imgur.com/UNid7.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/UNid7.png" alt="enter image description here"></a></p>

<p><strong>What is already working:</strong>  </p>

<p>I make single tap on "6:00", which call my function <code>addAlarm ("6:00", "unstable")</code>. Button "6:00" was highlighted in green. Time itself was stored in the data model of the application, to the button with this time will be highlight after closing and reopening the application.</p>

<p>Button "8:00" is red, because I make double tap on it, which call function <code>addAlarm ("6:00", "stable")</code>. Information was also recorded in the data model.</p>

<p><strong>What I want:</strong>  </p>

<p>The green color of the button "6:00" means that the alarm should triggered once at 6 am, and then has to be deactivated: the button again to become blue. I have function for it <code>removeAlarm(time)</code></p>

<p>Red Button "8:00" means that the alarm should be triggered each day at 8 am, but after that the button should also be red.</p>

<p>Under the «alarm should be triggered», I mean the following. On the screen of the device should be the notice with text «Wake up», and begins to play a tune. The file with the tune has 20 seconds duration, but I want play tune 3 minutes, constantly repeating 20 second file with the tune.</p>

<p>Alarm should be triggered even when the application is minimized, the phone is in sleep mode, or set to "Not disturb".</p>

<p><strong>What I do not understand:</strong>  </p>

<p>Well, of course, how to do what I want :-) But seriously, I am not clear what methods to use. I managed to find the following.</p>

<p>I can use <a href="http://makeapppie.com/2015/04/24/swift-swift-using-nstimer-to-make-a-timer-or-alarm/" rel="nofollow noreferrer">NSTimer</a>, to call some callback after the appointed time, but the timers stop working after 10 minutes after minimizing the application.</p>

<p>I can and should use the <a href="http://jamesonquave.com/blog/local-notifications-in-ios-8-with-swift-part-1/" rel="nofollow noreferrer">UIApplication.sharedApplication().scheduleLocalNotification(notification)</a> for the appearance of the notice, but the melody for the notice may not be longer then 30 seconds. Also not clear to me, as I call my function <code>removeAlarm (time)</code> for the alarm, which was created for single time working, if the user does not respond to the notification, for example, will not wake up.</p>

<p>I can use the <a href="http://www.raywenderlich.com/92428/background-modes-ios-swift-tutorial" rel="nofollow noreferrer">Background Modes</a>.</p>

<p><strong>In general, the question is:</strong>  </p>

<p>What is, or what methods I should to use, how to combine them, and which direction is best to choose?</p>