When the app tries to access the Camera API's in iOS than an OS level alertview is shown. The user here has to allow access to camera or disable the access.
My question is how can I get notified of the selection made by the user..?
Say he selected don't allow access than is there any notification raised which I can use in my app..?
Any help is appreciated.
With this option, you can easily manage which app can access the camera. Step 1: Go to Settings > Privacy. Step 2: Tap on Camera to see which apps have access to it. You can allow or block apps using Camera from here.
Before apps use the camera or microphone on your iPhone, they're required to request your permission and explain why they're asking. For example, a social networking app may ask to use your camera so that you can take and upload pictures to that app.
Open the Settings app. Tap on Safari > Camera. Scroll down to Camera & Microphone. Confirm that "Ask" or "Allow" is checked.
Instead of letting the OS show the alert view when the camera appears, you can check for the current authorization status, and request for the authorization manually. That way, you get a callback when the user accepts/rejects your request.
In swift:
let status = AVCaptureDevice.authorizationStatusForMediaType(AVMediaTypeVideo)
if status == AVAuthorizationStatus.Authorized {
// Show camera
} else if status == AVAuthorizationStatus.NotDetermined {
// Request permission
AVCaptureDevice.requestAccessForMediaType(AVMediaTypeVideo, completionHandler: { (granted) -> Void in
if granted {
// Show camera
}
})
} else {
// User rejected permission. Ask user to switch it on in the Settings app manually
}
If the user has previously rejected the request, calling requestAccessForMediaType
will not show the alert and will execute the completion block immediately. In this case, you can choose to show your custom alert and link the user to the settings page. More info on this here.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With