Barcodescanner

🔎 A simple and beautiful barcode scanner.
Alternatives To Barcodescanner
Project NameStarsDownloadsRepos Using ThisPackages Using ThisMost Recent CommitTotal ReleasesLatest ReleaseOpen IssuesLicenseLanguage
Zxing Android Embedded5,260
7 months ago6October 25, 2021100apache-2.0Java
Barcode scanner library for Android, based on the ZXing decoder
Barcodescanner5,23353 years ago27August 19, 2017otherJava
Barcode Scanner Libraries for Android
Html5 Qrcode3,2974a day ago46April 07, 2022230apache-2.0TypeScript
A cross platform HTML5 QR code reader. See end to end implementation at: https://scanapp.org
Lbxscan3,014
1103 years ago5October 22, 2018148mitObjective-C
A barcode and qr code scanner (二维码、扫码、扫一扫、ZXing、ZBar、iOS系统AVFoundation扫码封装,扫码界面效果封装)
Zxinglite2,592
2 months ago4June 22, 202224apache-2.0Java
🔥 ZXing的精简极速版,优化扫码和生成二维码/条形码,内置闪光灯等功能。扫描风格支持:微信的线条样式,支付宝的网格样式。几句代码轻松拥有扫码功能 ,ZXingLite让集成更简单。(扫码识别速度快如微信)
React Native Qrcode Scanner1,9861719a month ago51February 11, 2022123mitJavaScript
A QR code scanner component for React Native.
React Native Camera Kit1,98346113 days ago185September 15, 202282mitObjective-C
A high performance, easy to use, rock solid camera library for React Native apps.
Qrcodereaderview1,770
2313 years ago2March 29, 201749Java
Modification of ZXING Barcode Scanner project for easy Android QR-Code detection and AR purposes
Barcodescanner1,631
339 hours ago16March 11, 201825otherSwift
:mag_right: A simple and beautiful barcode scanner.
Sgqrcode1,594
28a year ago21July 16, 20225apache-2.0Objective-C
The easy to use bar code and QR code scan library for iOS【支持二维码生成、图片中读取二维码、条形码和二维码扫描】
Alternatives To Barcodescanner
Select To Compare


Alternative Project Comparisons
Readme

BarcodeScanner

CI Status Version Swift Carthage Compatible License Platform

Description

BarcodeScanner is a simple and beautiful wrapper around the camera with barcode capturing functionality and a great user experience.

  • [x] Barcode scanning.
  • [x] State modes: scanning, processing, unauthorized, not found.
  • [x] Handling of camera authorization status.
  • [x] Animated focus view and custom loading indicator.
  • [x] Torch mode switch.
  • [x] Customizable colors, informational and error messages.
  • [x] No external dependencies.
  • [x] Demo project.

Table of Contents

BarcodeScanner Icon

Usage

Controller

To start capturing just instantiate BarcodeScannerViewController, set needed delegates and present it:

let viewController = BarcodeScannerViewController()
viewController.codeDelegate = self
viewController.errorDelegate = self
viewController.dismissalDelegate = self

present(viewController, animated: true, completion: nil)
BarcodeScanner scanning

You can also push BarcodeScannerViewController to your navigation stack:

let viewController = BarcodeScannerViewController()
viewController.codeDelegate = self

navigationController?.pushViewController(viewController, animated: true)

Delegates

Code delegate

Use BarcodeScannerCodeDelegate when you want to get the captured code back.

extension ViewController: BarcodeScannerCodeDelegate {
  func scanner(_ controller: BarcodeScannerViewController, didCaptureCode code: String, type: String) {
    print(code)
    controller.reset()
  }
}

Error delegate

Use BarcodeScannerErrorDelegate when you want to handle session errors.

extension ViewController: BarcodeScannerErrorDelegate {
  func scanner(_ controller: BarcodeScannerViewController, didReceiveError error: Error) {
    print(error)
  }
}

Dismissal delegate

Use BarcodeScannerDismissalDelegate to handle "Close button" tap. Please note that BarcodeScannerViewController doesn't dismiss itself if it was presented initially.

extension ViewController: BarcodeScannerDismissalDelegate {
  func scannerDidDismiss(_ controller: BarcodeScannerViewController) {
    controller.dismiss(animated: true, completion: nil)
  }
}

Actions

When the code is captured BarcodeScannerViewController switches to the processing mode:

BarcodeScanner loading

While the user sees a nice loading animation you can perform some background task, for example make a network request to fetch product info based on the code. When the task is done you have 3 options to proceed:

  1. Dismiss BarcodeScannerViewController and show your results.
func scanner(_ controller: BarcodeScannerViewController, didCaptureCode code: String, type: String) {
 // Code processing
 controller.dismiss(animated: true, completion: nil)
}
  1. Show an error message and switch back to the scanning mode (for example, when there is no product found with a given barcode in your database):
BarcodeScanner error

func scanner(_ controller: BarcodeScannerViewController, didCaptureCode code: String, type: String) {
 // Code processing
 controller.resetWithError(message: "Error message")
 // If message is not provided the default message will be used instead.
}
  1. Reset the controller to the scanning mode (with or without animation):
func scanner(_ controller: BarcodeScannerViewController, didCaptureCode code: String, type: String) {
  // Code processing
  controller.reset(animated: true)
}

If you want to do continuous barcode scanning just set the isOneTimeSearch property on your BarcodeScannerViewController instance to false.

Customization

We styled BarcodeScanner to make it look nice, but you can always use public properties or inheritance to customize its appearance.

Header

let viewController = BarcodeScannerViewController()
viewController.headerViewController.titleLabel.text = "Scan barcode"
viewController.headerViewController.closeButton.tintColor = .red

Please note that HeaderViewController is visible only when BarcodeScannerViewController is being presented.

Footer and messages

let viewController = BarcodeScannerViewController()
viewController.messageViewController.regularTintColor = .black
viewController.messageViewController.errorTintColor = .red
viewController.messageViewController.textLabel.textColor = .black

Camera

let viewController = BarcodeScannerViewController()
// Change focus view style
viewController.cameraViewController.barCodeFocusViewType = .animated
// Show camera position button
viewController.cameraViewController.showsCameraButton = true
// Set the initial camera position
viewController.cameraViewController.initialCameraPosition = .front // Default is .back
// Set settings button text
let title = NSAttributedString(
  string: "Settings",
  attributes: [.font: UIFont.boldSystemFont(ofSize: 17), .foregroundColor : UIColor.white]
)
viewController.cameraViewController.settingButton.setAttributedTitle(title, for: UIControlState())

Metadata

// Add extra metadata object type
let viewController = BarcodeScannerViewController()
viewController.metadata.append(AVMetadataObject.ObjectType.qr)

Installation

BarcodeScanner is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod 'BarcodeScanner'

Don't forget to set a Privacy - Camera Usage Description in your Info.plist file, else the app will crash with a SIGBART.

In order to quickly try the demo project of a BarcodeScanner just run pod try BarcodeScanner in your terminal.

BarcodeScanner is also available through Carthage. To install just write into your Cartfile:

github "hyperoslo/BarcodeScanner"

To install BarcodeScanner manually just download and drop Sources and Images folders in your project.

Author

Hyper Interaktiv AS, [email protected]

Contributing

We would love you to contribute to BarcodeScanner, check the CONTRIBUTING file for more info.

License

BarcodeScanner is available under the MIT license. See the LICENSE file for more info.

Popular Scanner Projects
Popular Barcode Projects
Popular Security Categories
Related Searches

Get A Weekly Email With Trending Projects For These Categories
No Spam. Unsubscribe easily at any time.
Swift
Camera
Scanner
Barcode
Barcode Scanner