Here's a simple guide to using the barKoder SDK in your Xamarin project:
To use the scanning features of the barKoder Barcode Scanner SDK, you need to grant camera permission. For Android devices, set the permission in the manifest from the package. For iOS devices, specify camera permission in the Info.plist file within your project:
<key>NSCameraUsageDescription</key>
<string>Camera permission</string>
BkdView = new BarkoderView();
var barkoderView = BkdView.View;
BkdView = new BarkoderView();
var BarkoderView = BkdView.View;
View.AddSubview(BarkoderView);
...
// TODO: Add constraints to BarkoderView
// In order to perform scanning, config property need to be set before
BkdView.Config = new BarkoderConfig("LICENSE_KEY");
BkdView.Config.DecoderConfig = new DecoderConfig();
private void SetBarkoderSettings()
{
// These are optional settings, otherwise default values will be used
BkdView.Config.ImageResultEnabled = true;
BkdView.Config.LocationInImageResultEnabled = true;
BkdView.Config.RegionOfInterestVisible = true;
}
private void SetActiveBarcodeTypes()
{
/// There is option to set multiple active barcodes at once as array
BkdView.Config.DecoderConfig.SetEnabledDecoders(
new NSNumber[] {
(int)DecoderType.Qr,
(int)DecoderType.Ean13
}
);
// or configure them one by one
BkdView.Config.DecoderConfig.UpcA.Enabled = true;
}
private void SetActiveBarcodeTypes()
{
/// There is option to set multiple active barcodes at once as array
BkdView.Config.DecoderConfig.SetEnabledDecoders(
new BKD.DecoderType[] {
BKD.DecoderType.Qr,
BKD.DecoderType.Ean13
}
);
// or configure them one by one
BkdView.Config.DecoderConfig.UpcA.Enabled = true;
}
Upon entering the callback function MethodResultCallBackDecoderResultWithCompletion, the SDK has completed its initialization and is now ready for configuration or scanning.
// Starting to scan
BkdView.StartScanning((result) =>
// Fetching data
// TODO: Getting results
);
// Starting to scan
BkdView.StartScanning(this);
// Fetching data
public void ScanningFinished(BKD.Result[] results, Bitmap resultImage)
{
// TODO: Getting results
}
The SDK will scan barcodes even without a valid license; however, all results will be randomly masked with (*) Asterisk characters. By using our software you are agreeing to our End User License Agreement. To obtain a valid license, one should create an account here and either get a trial license (to test the software out) or procure a production license that can be used within a live app.