Search code examples
iosobjective-ccameradeep-linking

How can I open native camera from my app on iOS?


I need open the native camera app when a function was called. I just need redirect to native camera app. I don't want to get any image.

I am trying with this code:

        NSURL *url = [NSURL URLWithString:@"some-camera-deep-link://"];
        
        if ([[UIApplication sharedApplication] canOpenURL:url]) {
            [[UIApplication sharedApplication] openURL:url options:@{} completionHandler:nil];
        } else {
            NSLog(@"some error");
        }

However, I don't know the exact URL I need to set and how configure this in my Info.plist.

Is possible do this kind of navigation? Can you show some example?

I don't want to use UIImagePickerController.


Solution

  • Unfortunately, you can't. There are a few URL schemes that are supported by the system. And the camera is none of them. You have to use a built-in component such as UIImagePickerController or create a new one on your own.

    AFAIK, at most, you can able to open the gallery with this photos-redirect://.

    This document indicates all these supported links.

    Updated: I've found this helpful repo if you're curious.