How to create an alarm clock app with swift?

梦想与她 提交于 2019-12-06 07:49:51

问题


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.


回答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.

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.




回答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



来源:https://stackoverflow.com/questions/30890766/how-to-create-an-alarm-clock-app-with-swift

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!