Note that there are some explanatory texts on larger screens.

plurals
  1. POiPhone alarm using repeated local notifications
    primarykey
    data
    text
    <p>I'm trying to add an in-background alarm clock feature to an app I'm developing.</p> <p>I have read up on the <code>UILocalNotification</code> object and its use, and am aware that it is limited to 30 seconds of audio.</p> <p>I was thinking of scheduling multiple notifications (say, 5 of them) spaced 30 seconds apart to mimic continuous play, but the problem with this approach is that if the user hits <code>Close</code>, I won't be able to cancel any of the subsequent notifications.</p> <p>As far as I know, it is impossible to remove or hide the <code>Close</code> button without hiding the notification entirely (i.e., setting the <code>alertBody</code> property to <code>Nil</code>).</p> <p>So, I thought I might use the <code>repeatInterval</code> property to cause the notification to pop up every 30 seconds, but it seems that I can only set the interval to one minute or one second, and nothing in between.</p> <p>The feature is meant to allow the user to choose between music and beeps for alarm audio; it seems I may have found a way to do the beeps - setting the <code>repeatInterval</code> to one second, create a second's worth of beeps (which would need to be timed to cleanly repeat) and use that as the notification sound.</p> <p>However, for the music, this approach limits me to playing 30 seconds of audio, followed by a 30-second gap, followed by 30 seconds of audio, and so on.</p> <p>I know that there is no straightforward solution here, from my reading of other posts and resources; no third-party app has access to the same functionality as the built-in alarm clock. I am hoping that someone has found a workaround or thinks of something really clever.</p> <p>UPDATE: I have found that the <code>repeatInterval</code> doesn't help me in this case, as I can't cancel the repetitions without launching the app.</p> <p>For the time being I have decided not to use a notification as an alarm per se, but have changed the feature to be a reminder (more along the lines of what the notification is intended for).</p> <p>If I come up with a way to implement user-friendly, reliable alarm functionality to an app, I will update this post.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload