NSString *mediatype = Avmediatypevideo; Or avmediatypeaudioavauthorizationstatus authstatus = [Avcapturedevice Authorizationstatusformediatype:mediatype] ;//This status was normally not Visible-the Avcapturedevice class methods for discovering devices does not return devices th E user is restricted from accessing.if (authstatus = = avauthorizationstatusrestricted) {NSLog (@ "restricted");} The user has explicitly denied permission for media capture.else if (authstatus = = avauthorizationstatusdenied) {Nslo G (@ "Denied");} The user has explicitly granted permission for media capture, or explicit user permission are not necessary for the Medi A type in Question.else if (authstatus = = avauthorizationstatusauthorized) {NSLog (@ "Authorized");} EXPLICIT user permission is required for media capture, but the user have not yet granted or denied such permission.else if (Authstatus = = avauthorizationstatusnotdetermined) {[Avcapturedevice Requestaccessformediatype:mediatype completionhandler:^(BOOL granted) {//Make sure we execute our code on the main thread so we can update the UI immediately. See documentation for Abaddressbookrequestaccesswithcompletion where it says//"The completion handle R is called in an arbitrary queue. " Though there is no similar mention for Requestaccessformediatype, it appears it does//the same thing . Dispatch_async (Dispatch_get_main_queue (), ^{if (granted) {//UI updates as needed NSLog (@ "Granted access to%@", mediatype); } else {//UI updates as needed NSLog (@ "Not granted access to%@", mediatype); } }); }];} else {NSLog (@ "Unknown authorization Status");}
How to use the iOS system camera gracefully