EPCqrScanner 0.7.0

EPCqrScanner 0.7.0

Maintained by Geza Csiki.



  • By
  • Geza Csiki

EPCqrScanner

Scanner for the European Payments Council Quick Response Code

xCode Swift License Platform

Requirements

  • iOS 10.0+
  • Xcode 10.1+
  • Swift 4.2+

Installation

CocoaPods

CocoaPods is a dependency manager for Cocoa projects. For usage and installation instructions, visit their website. To integrate EPCqrScanner into your xCode project using CocoaPods, specify it in your Podfile:

pod 'EPCqrScanner'

Install into your project:

$ pod install

Open your project in xCode from the .xcworkspace file (not the usual project file):

$ open MyProject.xcworkspace

You can now import EPCqrScanner framework into your files.

Usage

In iOS10+, you will need first to reasoning about the camera use. For that you'll need to add the Privacy - Camera Usage Description (NSCameraUsageDescription) field in your Info.plist:

privacy - camera usage description

Create your own codeReader and videoLayer properties on the ViewController on which you want to use the EPCqrScanner.

private var codeReader = EPCqrScanner()
private var videoLayer: CALayer!

Also you need a IBOutlet for the camera preview:

@IBOutlet weak var videoPreview: UIView!

Start the EPCqrScanner in viewWillAppear and handl the response.

override func viewWillAppear(_ animated: Bool) {
    super.viewWillAppear(animated)
    codeReader.startReading { [weak self] (qrResult) in
            //TODO: use response
    }
}

The qrResult can be nil, if the QR does not conform to the EPC Standards. (See EPC Standards) \nOtherwise the respons has EPCqrResult type.

EPCqrResult contains obligatory the name and iban.

Assign the Camera preview to your view in viewDidload:

override func viewDidLoad() {
    super.viewDidLoad()
    videoLayer = codeReader.videoPreview
    videoPreview.layer.addSublayer(videoLayer)
}

License

EPCqrScanner is released under the MIT license. See LICENSE for details.