Wednesday, July 21, 2010

iPhone 4 light apps

There are at least 50 iPhone 4 light apps now, which have one or more of the following features: turn on/off the torchlight on the back of the phone, and strobe the torchlight.
That's it. Half of those apps cost $0.99, and probably most of the rest have ads enabled.

I thought it was pretty stupid, and I was also told the apps are slow to start up. One of them takes 5 seconds just to load up. So I felt the need to write in 2 hours a light app with strobing, including separate controls for light/dark timings of the strobe. Kind of fun. The app loads in less than 2 seconds and is well under 100kB.

If you want the source code, just let me know.
Update: I've just submitted the app to the AppStore, called "☼ Flashlight ☼"
Update 2: It's available on the app store.
Please leave a comment here in this post if you have issues or suggestions with the app. Thanks.
The "light" app in all its glory


Lim said...

Hey Rik, I'm starting to learn about iPhone development and was looking for a light app when I found yours. Alas, my iPhone is the 3GS and so it doesn't work with your app. I thought it'd be a cool exercise to learn by example -- if you'd like to share your source to help me learn, I'd appreciate it!

CaliMobber said...

I love your app, So far hands down my favorite flashlight app. simple and to the point. Could you please ad a small button to start app with screen dark and tap to light up? Its not vital but would be a nice perk to seal the deal.

Thanks! also is there a way to donate?

Rik said...

@CaliMobber, thanks for the praise. It actually took quite a bit of time to design that interface the way it is.:) Regarding your request, why don't you simply turn on the light, darken the screen and quit the app? Next time it will simply open with a darkened screen and the light on. That's how many people use it. The app remembers exactly what state it was left in (except for one upcoming change -- see below).

Please don't even think of donating. The whole app is about 200 lines of code including comments. I just wanted to show all those app devs writing bloated and/or paying flashlight apps that they're screwing the users.

The next version (1.3) will have a "shake for SOS" option, which should pretty much close out all the possible features of a light app. If someone activated SOS mode and then quit the app, it will not restart in SOS mode, but in the default off mode. That's the only exception to the rule. The new version should be up on the app store in a few days (oh, and it's got a better icon too).

Ky said...

Woah, I am impressed. Of course your ratings on the App Store are incredible, so I downloaded the app. They are blew away the other guys, and have embarrassed those charging for their flashlight apps. Thanks for your selflessness and for a great product! I'm just wondering if my friends with the new iPod Touch can benefit? Nothing listed on the App Store about the Touch.

Rik said...

Thanks @Ky. The funny thing is that as I restricted myself to the core iOS user interface to reduce size and loading time, this was pretty much the only possible UI. (I love how the whole app is 20k in size...)
The app is restricted to those devices having a LED flash. I don't specify "iPhone 4", so if the new iPod Touch has a LED flash, it should work. I don't think it has it, but it doesn't hurt to try.

jlundell said...

Nice, clean app. Let me see if I can dirty it up for you.

I was wondering how much (time) resolution you're given over the LED on/off timing. If it's down in the ms range, it should be (relatively) easy to use PWM to give a brightness control, which would also proportionately reduce power draw.

That would be handy, because the LED is actually too bright for close work, say reading something in a dark room.

Rik said...

@jlundell: unfortunately, empirically you can't get much lower than 10ms in turning the LED on or off.
You can test this in the app: synchronize the light and dark sliders and move them all the way left. Then activate the strobe. This gives a 10ms strobe, but as you will see it's barely consistent. Sometimes it'll skip a frame, so I don't think there's any way to get to millisecond speeds reliably.

I have to use timers to get the times exact, and I think my code is as efficient as I can make it. If I don't use OS timers I can't get reliable intervals.

Steve Kroser said...

Fantastic App!! Thanks. For some reason it stopped working on me (iPhone 4), the led wouldn't come on. I deleted and reinstalled and it now works fine.

Rik said...

Steve, can you try to see if there's a log file you can send me?
I suspect that the problem is that the app is so small it never leaves memory, and the iOS must have a bug where it won't clean things properly.
If this happens again to you, please just quit the app (forcefully press the "-" button in the list of active apps to kil l it) and see if it fixes the problem.

Don Moore said...

Rik. When you suggest killing the active app ("-") are you referring to a function available on the phone or in iTunes? I am experiencing the problem that the light no longer comes on when the app is opened. Thanks.

Rik said...

I meant on the phone. Go back to the home view, then double-click the bottom button. You'll see a list of active apps. Scroll sideways to find the light app, then tap on it for a coupke of seconds. A "-" sign should appear on it. Tap it, it'll quit the app. Then press the bottom button again to go back to the normal view.

If that doesn't work, simply reboot the phone. That'll often solve many many problems :)

Anonymous said...

App version 1.4 doesn't work on iOS 4.1 devices. Can you fix this?

Rik said...

@adawen, apologies for this major mistake.
A new version (1.5) has already been submitted to Apple fixing this, as well as I believe finally working around a complicated iOS bug that would stop the app from lighting the flash under very low memory. (the current solution is simply to force quit the app or reboot the phone)

So i'd appreciate if you could wait a few days until the app is approved by Apple. Thanks!

Anonymous said...

Hi @Rik, Got the updated version and it's working. One problem is if the app resumed from multitask-bar w/ light previously on, the light won't come up. Previous version works well.

Rik said...

@adawen, this is the first I hear of this. How can I replicate it? Resuming from the task bar or tapping the icon on the springboard should be the exact same thing. Are you certain that you left the light on before switching to another app? The app always returns to the exact configuration it had upon leaving it previously.

Anonymous said...

Hi @Rik, I think it's a rare case due to my iPhone4 was having so little free memory (and then panic-ed), After the reboot things back to normal...really sorry about bugging you.

Bas Könst said...

Hi Rik,
thanx for a great app !
I have a suggestion : How about adding a function with which the user can enter text which will then be flashed in morse ?
That would really be helpful in an emergency situation.


Rik said...

@Bas, I really want to keep the app as small as possible so it can load instantly and use a minimal amount of memory.
I was thinking of making another couple of apps, one that would focus on the strobe with manual or sound activation for parties, and another specifically for morse.
As soon as I get the time I'll make them. :)

Anonymous said...

I wrote my own application with the SDK flashlight. I thought it would be another now. It has to invoke device capabilities means that will drain the batteries as well as a video recording. Maybe I should send mine for approval. I do not think it would be a point.

ipad wholesale

Anonymous said...

An idea for another feature: display the keyboard and send the letters typed as morse signals.

Rik said...

@hussman I thought about that, but I'll keep this app streamlined the way it is. I've got ideas for another app that would do sound-based strobing as well as morse and possibly something else that I need to technically test and could be fun and unique.
As soon as I have time!

J.D. Lien said...

I was thinking that it would be neat to have a little reference that could be popped up that shows a table of morse code patterns for those who want to signal morse.

That should be fairly trivial to implement and not increase the complexity of the program too much, no?

Great app, btw :)

Paul Förster said...

Hi Rik,

great app! But it has a bug on my wife's iPhone 4 (4.3.5). Switching the light on makes it strobe just very, very fast while on my iPhone (same model, same iOS) it is constantly on as it should be.

Also, two feature requests:

1. Could you add a keyboard that lets one type a message and the app will morse code it?

2. Could you add a switch that, in addition to morse, makes the morse code sound accordingly? Just an on/off switch would be great.



Rik said...

Hi Paul, are you sure that your wife's app is in the "On" position and not "Strobe"? If so, then either fully quit the app (not just leaving the app) or reboot the phone.

For your suggestions, I'm still considering whether I should add the features or leave it optimized as-is. Anything I add will make the app slower (even if by just a tiny bit) unless I find more juice to squeeze out of it, which I doubt.
Maybe that's worth making another app just for morse code.

Paul Förster said...

Hey Rik,

yes, she switched on, and I asked her if she hit "Strobe". She said no and I checked. Then I tried, I rebooted the iPhone and the effect remaind. I tried her Apple camera app and that switched permanently on and off without strobing. But the "On" button made the led switch on and off very fast, i.e. much faster than the "Strobe" button, which I tried too, of course.



Anderson Hyde said...

I really like your app. Great stuff. One thing I might consider...I prefer to hold the manual control rather than flicking the light on...saves the battery. The phone is hard to hold in one hand though when you do that. Could you move that button up above the strobe controls? Then I can hold the phone solidly in one hand. Thanks for the great ap.

Alicia said...

I know this is an old post, but I wanted to let you know that the most recent update to this app is only compatible with iPhones with iOS other words, only AT&T iPhones. Verizon iPhones are still on 4.2.10 so we can't install the update.

Rik said...

@Alicia I didn't know that. I was timing the release of the app with the release of iOS 5 but Apple was quick in approving it. You'll be able to upgrade next week as soon as iOS 5 is released.
Sorry about that timing disconnect. There's nothing major in the new version, just that I made it even faster and smaller, and I modified the icon and layout to make them seem iOS 5 native.

Chriz said...

1.7 doesn't start for me :-(
iPhone 4 16GB GSM with 5.0 GM

Rik said...

@chriz fully quit the app and reboot. Probably iOS glitch. I didn't change any of the core codebase and it's working well on my own 5.0 GM. No leaks, errors or warnings whatsoever.

Alicia said...

Thanks for the reply, I just figured I'd let you know about it. This has happened before with a few other apps I've downloaded, the developer wasn't aware their app wasn't compatible with Verizon iPhones due to the fact they have a different iOS version but once made aware the issue was corrected quickly. I'll be sure to update when I have iOS 5 on my iPhone.

Side note: I'm super excited about iOS 5! I just hope Verizon gives it to us the day it's released and doesn't make us wait, lol.

Dr. Bhavesh Parmar said...

Hi Rik,
Thanks for your great app. It is very optimised and smallest of all the apps.
The new version with the linen background & new icon is very good.
I have just 2 suggestions:
1. In the black screen (double tap to return screen), please add the top bar showing time & battery level. It won't increase the size of the app/startup time. ;-)
2. Sometimes I only need a white screen for softer light. For eg. when finding a key from the table at night. The LED light is sometimes more bright than the requirement. At present I use another free, small, optimised app "Just Light Flashlight" for this use. Can you add this functionality in this app?
Thanks again...

Rik said...

You'd be surprised how bright the status bar can be, when in the dark! That's the reason the app hides it when you tell it to darken the screen.
Just so you can get a sense of brightness, the text that says "double-tap to return" is only 20% white, i.e. a very very dark gray.

Wolfgang Rust said...

i've got the same problem like Chriz here: after updating to 1.7 the app won't start. As i can see from iTunes there are quite some more users having this problem. So please fix it asap. My configuration: iPhone 4 GSM, iOS 5 GM

Rik said...

@wolfgang, the easiest way for me to find out where the problem lies is if you can send me a crash log.
Here's where you can find the logs after synching to the computer:
crash logs

I haven't changed anything in the core codebase, it works perfectly on my iOS 5 GM as well as that of the Apple testers, so I suspect some kind of OS bug. The earlier I can pinpoint it, the faster I can work around it and get Apple to fix it. Thanks!
You can send me the logs directly at the email address referenced at

Transporter said...

Hi Rik,

found your app two days ago in iTunes and today I wanted to load it, but for some reason it's not available anymore in the German App Store. Completely gone nice yesterday. :(

Is that only temporary, do you know anything about that? Thank you!

Rik said...

@Transporter, indeed. I removed v 1.7 from all stores except US & UK because I found a critical crash-on-start issue whenever phones are using non-english language. The problem is with the latest Xcode being rather finicky, to say the least.
Anyway, v 1.7.1 is in review as we speak, and should be live in the next couple of days. I'll re-enable all stores then.
Thanks for your patience!

Blacklight said...

Ok thanks for the quick answer! I'll wait then. :)

Blacklight alias Transporter, changed my name)

Rik said...

Version 1.7.1 has been released and should be back soon on all app stores.
It solves the non-English crashing problem and adds back support for iOS 4.0-4.2 for Verizon users who are still on 4.2.10.
Thanks for your patience.

scrag said...

Hi Rik.

Found a small issue with the app. When it's initially opened the LED gives a quick blip. This does not occur if it's started from the multi task bar. iPhone 4 IOS 4.3.5

Rik said...

@scrag very very good catch!
Here's the reason: Now the app defaults to start with the light on, and it turns off once it has acquired the saved preferences.
I did that to accelerate the speed at which you get the light from startup, which is the whole point of the app :)
I could revert back, but I don't think it'll bother people too much, especially since they generally will be wanting to have the light on by default.

scrag said...

Thanks Rik. I thought that there must be an explanation but thought to bring it to your attention anyway just in case you may have missed something. No further "issues" with the app and love it. As a pilot it comes in so handy everywhere and use it daily.

jab said...

Hi love this app I've been using it about a year now everyday. I got the latest update Oct 10th and the app ran fine as usual, but last night it stopped working. The screen turns black for a couple seconds then crashes to the home screen - I've tried rebooting, respringing, reinstalling, etc. to no avail. Only thing I can think that changed is I synced last night for the first time since last update. Any help here would be appreciated.

Rik said...

@jab that's a new one. If you could send me the crash logs I'd appreciate it. Also does the camera flash work in the camera/video?

jab said...

Hi Rik, I checked the camera app and the flash doesn't work there either. What's really strange is that the picture shows up in color for a split second then goes to black and white. I uploaded the crash logs for you, but I'm pretty sure now there's something else wrong with the phone, not your app. I'm going to restore and see if that fixes the problem.


Rik said...

@jab I concur with your assessment. The crash you sent me is happening inside the iOS in:
[AVCaptureFigVideoDevice setTorchMode:]

Something is wrong with your phone. Maybe a complete restore will fix it. Sorry to be a bearer of such bad news.

Yaw Anokwa said...


this is a great app! just two quick suggestions.

if you are handing out the code, you should consider putting it on github. i have ideas on how to clean up the ui and i'd be glad to submit patches.

also, to help make your app more popular why not do some timing tests of your app against the 'flashlight ®' app from i4software. as a consumer, i'm still tempted to try that one because i don't know if the flashlight could be faster. just some rough numbers in the description would be great.



S P said...

Mark me as one of the few that don't like the quick blip of light at launch. I prefer to use the manual button rather than have the light default to on.

Geno said...

Thank you very much for this simple but essential, elegant tool. There's so many flashlight apps out there, I was lucky to find yours.

Jacques said...

What's new in the Flashlight 1.7.2 update? There are notes in iTunes, nada.

thanks, best Flashlight app by far - interesting how there are so many, but none are as good

Rik said...

The app store is screwy right now. It should fix itself in the next 24 hours. The update 1.7.2 removes the very short flash on startup, removes the battery % in the main screen but adds it to the darkened screen. I removed the battery % from the main screen because the iOS doesn't give the apps as precise a number as it shows on the top bar, and that was annoying and confusing. On the other hand, having it on the darkened screen where the top bar is hidden is useful.

SHATT3R3D said...

I absolutely love this app!!! There is no doubt that this is the best flashlight app on the App Store! If I may make a suggestion, is it possible for you to to add a URL scheme for other apps to link to this app? I would love to be able to use an app like Launch Center to link to this app. (If you don't know what I mean, typing "sms:" without the quotes in the Safari address bar opens the Messages app, I would like this functionality for your flashlight app.) Thanks again for making the best flashlight app ever!

Bill C said...

A flashlight app is something I need so I was pleased to see the reviews for Flashlight by Rik. I have an iPhone 4 and just downloaded iOS6.

I've downloaded the app (I've done it a couple of times just to make sure it wasn't a problem from the download)

Anyway, it downloads fine but simply will not work. Any other folks having this problem?



Rik said...

@Bill C, it's most probably due to another app having locked the configuration of the torch, so that the Flashlight app can't take it over.
I suggest the easiest thing to do: Reboot your phone.
If that doesn't work, then I'd be very very surprised.

Marina said...

I have a small question for you about the source code for this. I have an app with a rather unrelated purpose, but I also use a dark screen with brightness set to 0. If I suspend my app with that dark screen on, it does not restore brightness to the previous level, unlike your app does. What do you do in your code to ensure this behaviour?


Rik said...

@Marina: Apple removed the ability for an app to reduce the brightness many versions ago (I think by iOS 3). An app isn't allowed now to reduce the brightness.
The way I do it is simply to display a black view, there's just no other way.

Phred said...

I love that this app simply works, without bloat, ads, or cost. The one feature I would request, however, is a simple on-off page that shows only an on-off button. Perhaps the current interface could become a "prefs" dialog and the actual use of the light could be reduced to that single button? I wouldn't mind if the download were an extra 50KB or so to accomodate a small image or two.

SO not complaining, though.

Rik said...

@Phred: please note that the app remembers all its settings between launches.
What I do is simply leave the light on with the screen dimmed when I quit the app. This way if I need the light on I just launch the app. Light off? Just press the home button, app quits. It's so fast that there's no need to have another screen like you suggest, IMHO.

Colin Barton said...

Hi Rik, I LOVE your app. But on the strobe setting the control for dark strobe is "grayed out" and not adjustable.
Your advice is sought. you can email me at thx

Jae Choon said...

Hey Rik.. The app is so simple and delivers what the user needs.. not more not less .. Can you share your source code? I am playing with flashlight and trying to implement a strobe with exact frequency entered by the user..

Thanks for your awesome and simple app! The App Store rating talks itself!