As I have promised three weeks ago (and again a few days ago) I finally got around to writing this little how-to.
I’m sorry for the delay. I hope this helps someone, anyway.
Mind you, this is my first attempt at writing a how-to and most of it was done while I was being tired. Also, English isn’t my native language, so please excuse any typos or other errors you may find.
If you have any suggestions on how to improve this how-to, please feel free to leave a comment.
Now, have fun!
Preface
We will create an iPhone application, that prevents the iPhone from deep sleeping while the app is running. It’s not a really useful application, as it does nothing but just that, but you can easily adapt the stuff you learn here and use it for your own application(s).
Here’s exactly what we’re going to do:
We will …
- … create a new project in Xcode.
- … add the necessary frameworks to this project.
- … add a silent sound file to this project.
- … create a class called “DeepSleepPreventer” and add it to this project.
- … then use this class to prevent the iPhone from deep sleeping.
You can use this class in your apps to prevent the iPhone from deep sleeping, while they are running. Just add the needed frameworks and the DeepSleepPreventer class to your app and use the DeepSleepPreventer, whenever you need it.