raziiq
raziiq

Reputation: 549

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.

Upvotes: 5

Views: 3104

Answers (2)

raziiq
raziiq

Reputation: 549

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 !!!

Upvotes: 1

DenNukem
DenNukem

Reputation: 8254

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.

Upvotes: 1

Related Questions