Archive for the ‘Development’ category

How-to: Prevent iPhone from Deep Sleeping

August 23rd, 2009

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, how to improve this, please feel free to leave a comment.

Now, have fun!

Preface

We will create an iPhone application, that keeps the iPhone from deep sleeping, while it’s 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 other apps, to prevent them from sleeping. Just add the needed frameworks and the DeepSleepPreventer class to your app and use the DeepSleepPreventer, whenever you need it.

» Read more: How-to: Prevent iPhone from Deep Sleeping

Timers and Locked Screen/Sleep Issues

July 28th, 2009

We all know, on the iPhone and iPod touch there are certain limitations for us, as developers.

The first one, I’ve encountered, while developing my second app, named “TuneAlarm”, was that it’s not possible, to execute any timers, while an app is active, but the iPhone/iPod touch is in sleep mode (that is, the screen is turned off/locked).

The app is basically an alarm clock, that wakes you with your favorite song straight out of your iPod Music Library.

Of course I knew, it isn’t possible to run your app in the background, but I thought this wouldn’t be a problem for TuneAlarm, as long as the user doesn’t switch to another application. I didn’t have deep sleep on my bill.

» Read more: Timers and Locked Screen/Sleep Issues