Detect existence of camera in iPhone app?


I'm writing an iOS app, and I need to be able to detect if the device has a camera. Previously, I would check if the device is an iPhone or not, since only the iPhone has a camera - but with the launch of the iPod Touch 4 this is no longer a viable option. The app functions without a camera, but the presence of a camera adds functionality.

So, can anyone provide me with code that returns whether there is a camera or not?


To check of camera is available (Swift)


If you need to know whether the device specifically has a front or rear camera, use this:

isCameraAvailable = [UIImagePickerController isCameraDeviceAvailable:UIImagePickerControllerCameraDeviceFront];
By : RawMean

Swift 2:

if UIImagePickerController.isSourceTypeAvailable(.Camera){

    //Your code goes here
    //For example you can print available media types:



This video can help you solving your question :)
By: admin