Skip to content

RedP4nda/RPScanner

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

RPScanner

Build Status Twitter

Disclaimer:

  • This program is still under active development and in its early stage, consider that breaking changes and rewrites could occur before using it in a stable version

RPScanner is a wrapper around AVFoundation to use scanning capabilities of the iPhone Camera to detect Barcodes & QRCodes

Features:

  • Barcode types:
  • QRCode types:

The Basics

How to scan:

Configure Scanner initialization and destruction

@IBOutlet var cameraPreview: UIView!

var scanner: RPScanner? = nil

// MARK: - Controller / Views initialization

override func viewDidLoad() {
    super.viewDidLoad()
    initScanner()
}


override func viewWillDisappear(_ animated: Bool) {
    super.viewWillDisappear(animated)
    clearScanner()
}

func initScanner() {
    scanner = RPScanner()
    scanner?.viewForPreview = self.cameraPreview
    scanner?.delegate = self
    scanner?.useFrontCamera = false

    if AVCaptureDevice.authorizationStatus(forMediaType: AVMediaTypeVideo) ==  AVAuthorizationStatus.authorized {
        self.scanner?.start()
    } else {
        AVCaptureDevice.requestAccess(forMediaType: AVMediaTypeVideo, completionHandler: { (granted :Bool) -> Void in
            if granted == true {
                self.scanner?.start()
            }
        });
    }
}

func clearScanner() {
    scanner?.stop()
    self.scanner = nil
}

Implement RPScannerDelegate methods to handle scanned events

func scanCodeDetected(_ code: String, barcodeType: String) {
  // do something
}


func scanCodeFailedWithError(_ error: NSError) {
  // handle detection error
}

Installation

Cocoapods

RPFramework can be added to your project using CocoaPods by adding the following lines to your Podfile:

source 'https://github.com/RedP4nda/Specs'

pod 'RPScanner', '~> 0.9'

Contributors

MrCloud

Partner

Contributing

Contributions are very welcome 👍😃.

Before submitting any pull request, please ensure you have run the included tests (if any) and they have passed. If you are including new functionality, please write test cases for it as well.

About

A simple barcode/QRCode scanner for iOS

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors