3

I've built a flashlight app, how can I put a restriction in place so it will only install on devices with a L.E.D? I presume UIDeviceRequiredCapabilities, but not sure which key/value to use.

jszumski
  • 7,430
  • 11
  • 40
  • 53
totalitarian
  • 3,606
  • 6
  • 32
  • 55
  • If the device doesn't have an LED as per `[device hasTorch]` you should instead make the screen completely or almost completely white. It makes a pretty good flashlight then. – Abhi Beckert May 04 '13 at 11:10
  • I removed the Xcode tag because the question has nothing to do with Xcode. – Daniel Martín May 04 '13 at 13:52

2 Answers2

3

You can set the camera-flash key of the UIDeviceRequiredCapabilities properties to YES to make sure it will only install on devices that contain a "camera flash" (usually the torch)

Leon Lucardie
  • 9,541
  • 4
  • 50
  • 70
  • 1
    This is a much better solution than @patapple as this simply won't let the app be installed in the first place. – Jonathan King May 04 '13 at 14:32
  • 1
    Leon is correct. You can find a list of all of the `UIDeviceRequiredCapabilities` keys in the documentation: http://developer.apple.com/library/ios/#documentation/general/Reference/InfoPlistKeyReference/Articles/iPhoneOSKeys.html#//apple_ref/doc/uid/TP40009252-SW3 Information on setting the key in the .plist can be found in the documentation here: https://developer.apple.com/library/mac/#documentation/General/Reference/InfoPlistKeyReference/Articles/AboutInformationPropertyListFiles.html – So Over It May 05 '13 at 03:02
2

Here is a complete answer: Turn on torch/flash on iPhone

To check if the device has the torch or not, use this code:

AVCaptureDevice *device = [AVCaptureDevice defaultDeviceWithMediaType:AVMediaTypeVideo];

if ([device hasTorch]) {
     // The device has a torch
}
Community
  • 1
  • 1
BalestraPatrick
  • 9,944
  • 4
  • 30
  • 43