Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Alarm clock app in iOS

Tags:

I have to create an alarm clock app for the iPhone in which user can set alarm time and sound. In doing so, I have used UILocalNotification to set off the alarm.

Now, in UILocalNotification, first we get Notification Alert with option "Close" and "View". If the user taps on "View", then my delegate receives the application:didReceiveLocalNotification: message and the alarm sound plays.

But in the system-native alarm app, we don't see a notification alert; it just directly plays the alarm sound. How can I have my app use this behavior?

like image 340
AmitK Avatar asked Feb 25 '12 14:02

AmitK


People also ask

Does iOS have an alarm clock?

With the Clock app, you can turn your iPhone into an alarm clock. Just open the Clock app from the Home Screen or Control Center. You can also ask Siri to set an alarm for you.

Where is my alarm clock app on my iPhone?

The clock app is there. It's the small alarm clock icon at the top right side of screen once an alarm has been set, so you know you have an alarm set. That will not appear in the status bar on the iPhone XR. You will have to swipe down Control Center to see it.

Is there a Clock app for iPhone?

Clock is a timekeeping mobile app included with iPhone since iPhone OS 1, with iPad since iOS 6, and Mac since macOS Ventura. The app includes world clock, alarm, stopwatch, and timer functions. A Bedtime feature was added in iOS 10.


2 Answers

I agree with David. iOS built-in alarm app gets a special treatment from Apple to sound > 30 seconds while in the background. It seems to be using some private API to make it sound for a longer time even when it is in the background or closed. This is not available to other apps built outside of Apple, so don't even try to compete with it. If you buy all Alarm clock apps in the App Store (aka: approved by Apple) and try them one by one, you will see that they lack behind the built-in alarm app in the most important function of an alarm: i.e. "Sounding for a long period, in any state the app is in (active, background, or closed)"

Your best bet to simulate a background alarm is to make use of UILocalNotification for 30 seconds. If you really want to wake up your heavy sleeper, schedule to fire up five of these notifications sixty seconds apart or something like that, in the hopes they will wake up before the 5th notification ends.

Notice that with this method, your user who misses the alarm will get 5 popups on their screen when they wake up (less if they wake up during one of the alarm popups), so they'll be spending their first seconds of their morning closing those popups - not the greatest user experience.

Conclusion: Alarm Clock apps are good for foreground use only. Best Alarm app out there that will work in any state is the built-in Clock app made by Apple.

like image 188
MyCSharpCorner Avatar answered Oct 21 '22 23:10

MyCSharpCorner


This alarm behavior is not available to iOS apps. You have the ability to create local notifications and add sounds to them, but the sound length is limited. You cannot have a sound continuously play such as on the built-in alarm.

One option is to repeat the alerts. So your app would send an alert, wait some time then send another. You repeat a specified number of times or until the user interacts with your app. I don't think this would provide a great user experience, so I don't recommend it.

like image 38
David V Avatar answered Oct 21 '22 22:10

David V