Use Verifone Barcode scanner over MFi
Use Verifone Barcode scanner over MFi.
iOS 8.0 or higher.
pod 'AdyenBarcoder'
to your Podfile
.pod install
.github "adyen/adyen-barcoder-ios"
to your Cartfile
.carthage update
.Copy files from AdyenBarcoder
folder.
You need to add com.verifone.pmr.barcode
in the Supported external accessory protocols
into Info.plist
file
To run the example project, clone the repo, and run pod install
from the Example directory first.
To initialize Barcoder library simply get the shared instance and set your BarcoderDelegate
.
let barcoder = Barcoder.sharedInstance
barcoder.delegate = self
The only mandatory method is didScan(barcode:)
. This is where the result of the scan will be delivered. You can also receive state updates on didChange(status:)
.
@objc public protocol BarcoderDelegate {
@objc func didScan(barcode: Barcode)
@objc optional func didChange(status: BarcoderStatus)
@objc optional func didReceiveLog(message: String)
}
Barcoder library supports four modes:
@objc public enum BarcoderMode: Int {
case hardwareAndSofwareButton // Default mode. Both hardware button and software commands (startSoftScan, stopSoftScan) are enabled.
case hardwareButton // Only hardware button is enabled. Calls to software commands will be ignored.
case softwareButton // Only software commands are enabled. Clicking the hardware button will not trigger the lights.
case disabled // Disabled.
}
You can set the mode via the mode
variable on Barcoder.sharedInstance
. The default value is .hardwareAndSofwareButton
.
For starting a soft scan:
barcoder.startSoftScan()
To stop the soft scan:
barcoder.stopSoftScan()
stopSoftScan
after starting a startSoftScan
.There are five log levels available: None, Error, Info, Debug, Trace.
To set the log level simply set the variable on your Barcoder
instance:
barcoder.logLevel = .debug
You will receive each new log message via BarcoderDelegate
method didReceiveLog(message:)
.
You can enable or disable setting the interleaved2of5 variable on Barcoder
instance:
barcoder.interleaved2Of5 = true
It’s possible to customize the barcoder symbology with setSymbology(enabled:)
method:
//Should be called AFTER .ready event on `didChange(status:)`
barcoder.setSymbology(.EN_CODE11, enabled: true)
The full list of accepted symbology can be found on SymPid
enum.
//
// Do not forget to put in Podfile:
// use_frameworks!
// pod "AdyenBarcoder"
//
// And put in Info.plist file:
// "com.verifone.pmr.barcode" in the "Supported external accessory protocols"
#import <AdyenBarcoder/AdyenBarcoder-Swift.h>
@interface ViewController () <BarcoderDelegate>
@end
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
// Initialize
[Barcoder sharedInstance].delegate = self;
}
// Did scanned
- (void)didScanWithBarcode:(Barcode * _Nonnull)barcode {
NSLog(@"Scanned barcode: %@", barcode.text);
}
@end
If you have any problems, questions or suggestions, create an issue here.
MIT license. For more information, see the LICENSE file.