Skip to content

Instantly share code, notes, and snippets.

@danielCarlosCE
Last active January 25, 2019 16:17
Show Gist options
  • Save danielCarlosCE/564dd683058e3fa86cef728157028ad1 to your computer and use it in GitHub Desktop.
Save danielCarlosCE/564dd683058e3fa86cef728157028ad1 to your computer and use it in GitHub Desktop.
extension AVCodeReader: AVCaptureMetadataOutputObjectsDelegate {
func metadataOutput(_ captureOutput: AVCaptureMetadataOutput,
didOutput metadataObjects: [AVMetadataObject],
from connection: AVCaptureConnection) {
guard let readableCode = metadataObjects.first as? AVMetadataMachineReadableCodeObject,
let code = readableCode.stringValue else {
return
}
//Vibrate the phone
AudioServicesPlaySystemSound(SystemSoundID(kSystemSoundID_Vibrate))
stopReading()
didRead?(code)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment