Integrate the Image Scanner SDK

Prev Next

Android

Manifest Permissions

The SDK's manifest already declares the following, and they are merged into your app automatically:

<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.VIBRATE" />

<uses-feature android:name="android.hardware.camera" android:required="false" />
<uses-feature android:name="android.hardware.camera.autofocus" android:required="false" />

CAMERA is a runtime permission. Your app must request it before starting the camera. Decoding a bitmap does not need any permission. For example, decoding an image chosen with the Android Photo Picker needs no storage permission.

AAR artifact-based integration

The SDK integration with an aar file is a flat dependency.

To integrate the Image Scanner SDK into your Android project via aar file

  • Copy QRCodeScannerSDK.aar from the OneSpan Mobile Security Suite to the libs folder.

  • Add the following to your build.gradle file:

    repositories {
        flatDir { dirs 'libs' }
    }
    
    dependencies {
        implementation(name: 'QRCodeScannerSDK', ext: 'aar')
    
        // Required transitive dependencies
        implementation 'androidx.camera:camera-core:1.6.2'
        implementation 'androidx.core:core-ktx:1.18.0'
        implementation 'io.github.zxing-cpp:android:3.1.1'
    }

Maven-based integration

The SDK artifact is also delivered as a local Maven repository with transitive dependencies, and the package includes a documentation jar file to view the technical documentation in Android Studio (to be used in conjunction with the Maven repository).

To integrate the SDK via maven repository:

  1. Copy the maven folder from the published artifacts to the root folder of your application.

  2. Define the dependency in your build.gradle file: implementation 'com.onespan:sdk_qrcode_scanner_android:+'.

  3. Comment out any existing definitions, for example: implementation(name: 'QrScannerSDK', ext: 'aar').

CameraX dependencies

The SDK only depends on camera-core. To show a preview and feed camera frames to the SDK, your app also needs the rest of CameraX:

dependencies {
    implementation 'androidx.camera:camera-camera2:1.6.2'
    implementation 'androidx.camera:camera-lifecycle:1.6.2'
    implementation 'androidx.camera:camera-view:1.6.2'
}

Known issue with Samsung Galaxy A23

Due to a known issue with the camera on Samsung Galaxy A23, Cronto codes are not decoded properly with the default resolution. The solution to this issue is to increase the resolution using the following code snippet:

var imageAnalysisBuilder = ImageAnalysis.Builder().setTargetRotation(rotation)
// Set Resolution property only for Samsung Galaxy A23 model
if(Build.MANUFACTURER.equals("Samsung", true) && Build.MODEL.contains("A23")) {
imageAnalysisBuilder.setTargetResolution(Size(1080, 1920))
}
imageAnalysisBuilder.build().setAnalyzer(cameraExecutor, QrCodeAnalyzer())

iOS

You integrate the SDK into your iOS project via MSSImageScanner.xcframework, a dynamic framework.

You must embed MSSImageScanner.xcframework into your app. If you only link it, the app will terminate unexpectedly at launch!

To integrate the Image Scanner SDK into your iOS project

  • Embed MSSImageScanner.xcframework from the OneSpan Mobile Security Suite package to your Xcode project (linked framework and libraries):

    • In Xcode, go to Frameworks, Libraries, and Embedded Content and set it to Embed & Sign.

When using the camera, NSCameraUsageDescription should be added to the Info.plist file of the project.

You are now ready to use the Image Scanner SDK.

API reference documentation and sample applications

To learn more about the public APIs and their functions, exceptions, and error codes, refer to the technical documentation that is included in the product package for each SDK and each platform. In the product package, you can also find the sample applications provided for each platform to see examples of how the SDKs can be used.

These sample apps are intended only to demonstrate basic scenarios and SDK usage. They are not designed to be copied directly into production projects!