Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to run my app even after iPhone screen locks?

I want my app (LaunchDaemon) to keep running even if user locks the iPhone. My LaunchDaemon simply check a file and if some condition is true, it displays an Alert to the User. Its working great when iPhone is on Home Screen, but it is not working when user Locks the Screen.

I want something Similar to Alarm app of iPhone which will show an Alert even if the iPhone screen is Locked.

Any suggestions on how to do this? BTW i am developing for JB iPhone.

like image 787
raziiq Avatar asked Nov 05 '22 17:11

raziiq


2 Answers

OS powers down the device and suspends your app after about 30 seconds after screen is locked. However, if your app is playing a sound OS will not do that. Hence what you need to do is play a silent sound in a loop.

like image 157
DenNukem Avatar answered Nov 15 '22 05:11

DenNukem


Alright i have solved this problem too.

Here is a very good tutorial on how to prevent deep sleep of iPhone.

Prevent iPhone Deep Sleep

It took me quite sometime to made this work, as NSRunLoop was not running for me automatically.

Hope this will help someone else also.

Best of Luck !!!

like image 37
raziiq Avatar answered Nov 15 '22 04:11

raziiq