How to create an alarm clock app with swift?

21,371

Solution 1

I have been doing research on this for quite some time now. But didn't find any concrete way to do it. You have to use one of the following from the list and make a logic to awake the app from the background.

enter image description here

For the alarm you can go through the blog here. It's having the details, which you can use to make a logic with UIApplicationExitsOnSuspend in info.plist file.

Solution 2

As already suggested, since iOS 7 the only way to have an App running in background is allowing one of the Background Modes.

Background modes

You can find them in the Capabilities section in your project settings. As long as your App does not fall under one of these, you are out of luck :(...

I once tried to write a similar App to yours, and there is really no way to do that right now.

Cheers, TK

Share:
21,371
Talha ŞEKER
Author by

Talha ŞEKER

self-study maniac and thirsty for knowledge, interested in mobile stuff, hopefully become an entrepreneur and an engineer,

Updated on July 09, 2022

Comments

  • Talha ŞEKER
    Talha ŞEKER almost 2 years

    I'm trying to create a kind of alarm clock app with the swift but I could not figure out how to set an alarm model. I've tried UILocalnotification but I don't want my users to be involved the flow of alarm app other than setting the alarm. Then tried NSTimer and NSRunloop etc. but that didn't work either since those don't work when app gets background. So is there any alternative ways to do that? Any help and suggestion would be appreciated, thanks.

  • Talha ŞEKER
    Talha ŞEKER about 9 years
    Thank you but as far as I know background modes has their own restrictions that dont allow me to do that. In android inheriting service class gives quite much oppurtunities
  • James Takarashy
    James Takarashy about 9 years
    Correct, but unfortunately iOS has this restrictions because of battery life and performance. So as long as you wont "cheat" (like playing a sound when your timer ticks), you will not be able to write your app.
  • Talha ŞEKER
    Talha ŞEKER about 9 years
    Well then how do you think the original alarm clock app of ios work?
  • James Takarashy
    James Takarashy about 9 years
    :D its from Apple, they can do more than they provide to the developers ;)