I have read many of articles regarding on this issues that only adds lines of code on plist like:
Key : Privacy - Camera Usage Description
Value : $(PRODUCT_NAME) camera use
but i still got the same issue that
ERROR MESSAGE
'Attempted to start scanning on a device with no camera. Check requestCameraPermissionWithSuccess: method before calling startScanningWithResultBlock:'
It seems like it still do not have the permission on using the camera on the apps
but then actually how are we going to gain camera access on iOS device?
and this are my code
MTBBarcodeScanner.requestCameraPermission(success: { success in
if success {
do {
try self.scanner?.startScanning(resultBlock: { codes in
if let codes = codes {
for code in codes {
let stringValue = code.stringValue!
print("Found code: \(stringValue)")
if (stringValue != nil)
{ ... }
})
}))
self.present(alert, animated: true, completion: nil)
}
}
}
})
} catch {
NSLog("Unable to start scanning")
}
} else {
UIAlertView(title: "Scanning Unavailable", message: "This app does not have permission to access the camera", delegate: nil, cancelButtonTitle: nil, otherButtonTitles: "Ok").show()
}
})
in order to get access to the devices' camera you have to provide a Camera Usage Description. You do this in your Info.plist file.
Simply click the "+" icon next to where it says "Information Property List" and type Privacy - Camera Usage Description
. Then as a value provide a short usage info, for example "We need access in order to scan barcodes."
Hope this helps.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.