पर पहुंच का अनुरोध करें मेरे पास एक क्यूआर कोड स्कैनर वाला ऐप है जो ठीक काम करता है, लेकिन आईओएस 8 पर कैमरे की डिफ़ॉल्ट पहुंच "अस्वीकार" है। इसलिए मुझे सेटिंग्स में जाना है और मैन्युअल रूप से कैमरे का उपयोग करने के लिए ऐप एक्सेस देना है। मैं प्रॉम्प्ट कैसे बना सकता हूं जो कुछ कहता है "क्या आप इस ऐप को कैमरे का उपयोग करने के लिए एक्सेस देना चाहते हैं"?आईओएस: कैमरा
यहां कैमरा अनुमतियों के लिए मेरे कोड की जांच का नमूना है और फिर उपयोगकर्ता ने उन्हें अनुमति नहीं दी है तो अनुमति का अनुरोध किया है। हालांकि, अनुमति देने का लिंक कभी दिखाई नहीं देता है और अंत में केवल UIAlertView दिखाता है। जब मैं परीक्षण करता हूं तो स्थिति वास्तव में दी जाती है, तो क्या कोई कारण है कि यह अनुमति मांग नहीं रहा है? धन्यवाद!
इसके अलावा मेरे पास #import AVFoundation/AVFoundation.h है इसलिए यह मुद्दा नहीं है।
-(void) checkCameraAuthorization {
AVAuthorizationStatus status = [AVCaptureDevice authorizationStatusForMediaType:AVMediaTypeVideo];
if(status == AVAuthorizationStatusAuthorized) { // authorized
NSLog(@"camera authorized");
}
else if(status == AVAuthorizationStatusDenied){ // denied
if ([AVCaptureDevice respondsToSelector:@selector(requestAccessForMediaType: completionHandler:)]) {
[AVCaptureDevice requestAccessForMediaType:AVMediaTypeVideo completionHandler:^(BOOL granted) {
// Will get here on both iOS 7 & 8 even though camera permissions weren't required
// until iOS 8. So for iOS 7 permission will always be granted.
NSLog(@"DENIED");
if (granted) {
// Permission has been granted. Use dispatch_async for any UI updating
// code because this block may be executed in a thread.
dispatch_async(dispatch_get_main_queue(), ^{
//[self doStuff];
});
} else {
// Permission has been denied.
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Not Authorized" message:@"Please go to Settings and enable the camera for this app to use this feature." delegate:self cancelButtonTitle:nil otherButtonTitles:@"OK", nil];
[alert show];
}
}];
}
}
else if(status == AVAuthorizationStatusRestricted){ // restricted
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Not Authorized" message:@"Please go to Settings and enable the camera for this app to use this feature." delegate:self cancelButtonTitle:nil otherButtonTitles:@"OK", nil];
[alert show];
}
else if(status == AVAuthorizationStatusNotDetermined){ // not determined
[AVCaptureDevice requestAccessForMediaType:AVMediaTypeVideo completionHandler:^(BOOL granted) {
if(granted){ // Access has been granted ..do something
NSLog(@"camera authorized");
} else { // Access denied ..do something
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Not Authorized" message:@"Please go to Settings and enable the camera for this app to use this feature." delegate:self cancelButtonTitle:nil otherButtonTitles:@"OK", nil];
[alert show];
}
}];
}
}
यहाँ उत्तर दिया: http://stackoverflow.com/questions/24229422/accessing-the-settings-app-from-your -app-in-ios-8 –