SDK Initialization | Xamarin Document Scanner
License Key
In order to run the Scanbot SDK within your production app, you must purchase and use a valid Scanbot SDK license.
Each license key is valid only for a given app bundle identifier. You will be unable to use any of the SDK features if the license key is corrupted, expired, or invalid in any other way.
Trial License
The Scanbot SDK will run without a license for one minute per session! To get a free, "no-strings-attached" 7-day trial license, please submit the Trial License Form on our website.
Please kindly note that a trial license can only be used in a development and staging environment. You are not allowed to publish your app to the App Store, Play Store, or any 3rd party Android App Store with a trial license.
Purchase a Production License
To get pricing information and purchase a production license for the Scanbot SDK, please request a quote.
App Identifier
Every app has a unique identifier (sometimes also known as "bundle identifier" or "application ID"). Your license will be bound to this identifier. To request a trial license or purchase a production license you have to provide us the bundle identifier of your app.
Initialize SDK & Register License
We provide free "no-strings-attached" developer support for the implementation & testing of the Scanbot SDK. If you encounter technical issues with integrating the Scanbot SDK or need advice on choosing the appropriate framework or features, please visit our Support Page.
The Scanbot SDK must be initialized before usage. Make sure to run the initialization as early as possible.
We recommend implementing the initialization in the Application
class of the Android and Forms app, and in the AppDelegate
class of the iOS app.
Example code for defining and using the license key string:
- Xamarin.Forms
- Xamarin Native
private const string licenseKey =
"fXbN2PmyqEAZ+btdkSIS36TuX2j/EE5qxVNcZMXYErbLQ" +
"3OBnE10aOQxYI8L4UKwHiZ63jthvoFwUevttctBk0wVJ7Z" +
"+Psz3/Ry8w7pXvfpB1o+JrnzGGcfwBnRi/5raQ2THDeokR" +
"RB1keky2VBOFYbCfYt3Hqms5txF2z70PE/SBTMTIVuxL7q" +
"1xcHDHclbEBriDtrHw8Pmhh9FqTg/r/4kRN/oEX37QGp+Y" +
"3ogwIBbSmV+Cv+VuwtI31uXY3/GkyN/pSJZspIl+exwQDv" +
"O0O1/R/oAURpfM4ydaWReRJtjW8+b1r9rUgPERguaXfcse" +
"HlnclItgDfBHzUUFJJU/g==\nU2NhbmJvdFNESwppby5zY" +
"2FuYm90LmRlbW8ueGFtYXJpbgoxNDg0NjExMTk5CjcxNjc" +
"KMw==\n";
SBSDKInitializer.Initialize(application, licenseKey);
private const string licenseKey =
"fXbN2PmyqEAZ+btdkSIS36TuX2j/EE5qxVNcZMXYErbLQ" +
"3OBnE10aOQxYI8L4UKwHiZ63jthvoFwUevttctBk0wVJ7Z" +
"+Psz3/Ry8w7pXvfpB1o+JrnzGGcfwBnRi/5raQ2THDeokR" +
"RB1keky2VBOFYbCfYt3Hqms5txF2z70PE/SBTMTIVuxL7q" +
"1xcHDHclbEBriDtrHw8Pmhh9FqTg/r/4kRN/oEX37QGp+Y" +
"3ogwIBbSmV+Cv+VuwtI31uXY3/GkyN/pSJZspIl+exwQDv" +
"O0O1/R/oAURpfM4ydaWReRJtjW8+b1r9rUgPERguaXfcse" +
"HlnclItgDfBHzUUFJJU/g==\nU2NhbmJvdFNESwppby5zY" +
"2FuYm90LmRlbW8ueGFtYXJpbgoxNDg0NjExMTk5CjcxNjc" +
"KMw==\n";
SBSDK.Initialize(application, licenseKey);
Updating the License in Production Apps
To renew an expired license or extend a valid license with new Scanbot SDK features, you will have to update your app in the App Store / Play Store. The expiration date and the feature list of a license are contained in an encrypted data part of the license key string. This means a renewal or extension of a license will cause a new license key string to be generated.
License Checks in Production Apps
If your Scanbot SDK license has expired, any call of the Scanbot SDK API will terminate your app.
To prevent this you should always check for license expiration during the runtime by calling the method IsLicenseValid()
.
If this method returns false
, you should disable any usage of the Scanbot SDK functions or UI components.
We highly recommend implementing a suitable handling of this case in your app!
Example code for checking the license status:
- Xamarin.Forms
- Xamarin Native
if (SBSDK.Operations.IsLicenseValid)
{
// Making your call into ScanbotSDK API is now safe.
// e.g. SBSDK.UI.LaunchDocumentScannerAsync(..), SBSDK.Operations.ApplyImageFilterAsync(..), etc.
}
if (SBSDK.IsLicenseValid())
{
// Making your call into ScanbotSDK API is now safe.
// e.g. startDocumentScanner(), doSomeScanbotImageOperation(), etc.
}
Logging
When initializing the Scanbot SDK you can enable or disable logging of the SDK.
- Xamarin.Forms
- Xamarin Native
SBSDKInitializer.Initialize(application, licenseKey, new SBSDKConfiguration { EnableLogging = true });
SBSDK.Initialize(application, licenseKey, new SBSDKConfiguration { EnableLogging = true });
On Android logs are printed into LogCat as well as saved on the device. You can find them in Environment.getExternalStorageDirectory()/debug_logs/[package_name]
. Usually it is /sdcard/debug_logs/[package_name]
.
On Android from v3.7.0 you can also set EnableNativeLogging
to true, to enable C++ logging for low level debugging.
On iOS all logs are printed to the console. There will be no log files created by the Scanbot SDK.
While it may be useful for development, consider switching logging off in production builds for security and performance reasons!
Image Quality / Compression
SBSDKConfiguration
has two more optional properties that specify the image storage format and compression for temporary images. Temporary images are all images created by the document scanner, cropping UI, as well as all image manipulation functions like ApplyImageFilter
.
- Xamarin.Forms
- Xamarin Native
var configuration = new SBSDKConfiguration
{
...
StorageImageFormat = CameraImageFormat.Jpg,
StorageImageQuality = 80,
};
SBSDKInitializer.Initialize(application, licenseKey, configuration);
var configuration = new SBSDKConfiguration
{
...
StorageImageFormat = CameraImageFormat.Jpg,
StorageImageQuality = 80,
};
SBSDK.Initialize(application, licenseKey, configuration);
These are all the SBSDKConfiguration attributes you can set in your configuration:
/// <summary>
/// Gets or sets a value indicating whether logging should be enabled. True by default.
/// </summary>
public bool EnableLogging { get; set; } = true;
/// <summary>
/// Gets or sets the storage image format. The default storage format is JPEG.
/// </summary>
public CameraImageFormat StorageImageFormat { get; set; } = CameraImageFormat.Jpg;
/// <summary>
/// Gets or sets JPEG quality. Must be a value between 0 and 100, the bigger
/// the better the quality and the larger the resulting image size.
/// Used only when <see cref="StorageImageFormat"/> is set to <see cref="CameraImageFormat.Jpg"/>.
/// The default storage quality is 80.
/// </summary>
public int StorageImageQuality { get; set; } = 80;
/// <summary>
/// Optional storage base directory of the SDK to store images and other files.
/// Use this configuration property to overwrite the default storage directory of the SDK or leave null to use the default.
/// </summary>
/// <value>The file path of the storage base directory.</value>
public string StorageBaseDirectory { get; set; } = null;
public DocumentDetectorType DetectorType = DocumentDetectorType.MLBased;
/// <summary>
/// Optional storage encryption. Disabled by default.
/// </summary>
public SBSDKEncryption Encryption;
/// <summary>
/// Allows controlling whether the XNN pack optimizations should be used (Android only).
/// Default is true.
/// </summary>
public bool? AllowXnnpackAcceleration { get; set; }
/// <summary>
/// Enables GPU acceleration for TensorFlow ML models (Android only).
/// Default is true.
/// </summary>
public bool? AllowGpuAcceleration { get; set; }
/// <summary>
/// If true, CameraX will be used under the hood (Android only).
/// Default is true.
/// </summary>
public bool? UseCameraXRtuUi { get; set; }
/// <summary>
/// Set to `true` if logging in C++ native core should be enabled, otherwise `false`.
/// Default is `false`.
/// Note: Android Only.
/// </summary>
public bool EnableNativeLogging { get; set; } = false;
Want to scan longer than one minute?
Generate a free trial license to test the Scanbot SDK thoroughly.
Get your free Trial LicenseWhat do you think of this documentation?
What can we do to improve it? Please be as detailed as you like.