Advanced Topics

This section covers detailed topics about the Anyline SDK on .NET. You will not require knowledge about these advanced topics in your every day use of the SDK. However, in case you need specific information about certain topics in the Anyline SDK, it will be covered here.

Camera2 API - Enable hardware acceleration

In the MAUI Android quickstart guide it is described what features and permissions the AndroidManifest XML should contain. Newer devices might use the new Camera2 API, therefore hardware acceleration must be enabled in the activity that renders the camera. Depending on the device, it might not be enough to add a android:hardwareAccelerated="true" property in the <application> tag in AndroidManifest.XML. So if the camera screen stays black, it’s necessary to set the hardware acceleration directly in C#.

[Activity(Label = "My Activity", HardwareAccelerated = true, ...)]
public class MainActivity : Activity

NFC Reader - iOS

NFC Reader can only be used to scan passports on the iPhones from model 7 and up, running iOS 13 and up. A full example implementation is available in our .NET MAUI Example App on GitHub. To use the NFC reader, Apple requires that the project includes a specific Entitlements.plist file, and is signed with a Provisioning Profile with NFC capability (note that Wildcard Provisioning Profiles cannot be used when signing projects with NFC capability). To create the required files, access the Apple developer portal and do the following:

  1. Create your Development Certificate

  2. Download the certificate and install it on your Mac host

  3. Create an App Identifier for your specific Bundle ID, with NFC Tag Reading capability

  4. Create a Provisioning Profile linked with your previously created Certificate and App Identifier

  5. Download the Provisioning Profile and install it on your Mac host

In the .NET-iOS examples app, we provide an Entitlements.plist file which is not referenced in the project. To start using the NFC reader follow these steps:

  1. Open the examples app solution in Visual Studio

  2. Right-click in the Anyline.Examples.MAUI project (not the solution) > Properties

  3. In the iOS Bundle Signing tab, find the Custom Entitlements field

  4. Search for the file Entitlements.plist, located in the root of the iOS project

  5. In Signing Identity and Provisioning Profile select the certificate and profile created in the Apple developer portal

  6. Save the changes

Error Messages

"codesign" exited with code 1.: Make sure that every time you change your signing configuration (Certificate, Provisioning Profile, Entitlements) you also erase the bin/obj folders before running the project.

(The executable was signed with invalid entitlements.): Your Provisioning Profile does not contains NFC capability and cannot be used with the Entitlements.plist file.

NFC Not Supported - NFC is not supported on this device: Make sure your device is compatible with NFC reading and you are referencing the right Certificate, Provisioning Profile and Entitlements.plist file in the project properties.

NFC Reader - Android

A full example implementation is available in our .NET MAUI Example App on GitHub. Android does not require as many configuration changes as iOS. To use the NFC reader, you will just need to:

  1. Add to your AndroidManifest.xml file the NFC Permission: <uses-permission android:name="android.permission.NFC" />

  2. Add to your AndroidManifest.xml file the NFC Feature: <uses-feature android:name="android.hardware.nfc" android:required="false" />

  3. Add a new Activity (Project > Add > New File > Android Activity) which will be responsible for receiving the NFC Tag events, and a xml Layout to provide feedback to your app’s users

  4. Use a standard NFCScanningViewRenderer for scanning the MRZ data

  5. Use the passport string from the MRZ Scan to unlock the NFC chip, inside the NFCScanActivity

Barcode - Android

When using the default Barcode scanner, the .NET-Android project may throw issues similar to this one: Unhandled Exception:Java.Lang.NoClassDefFoundError: Failed resolution of: Lcom/google/mlkit/vision/barcode/BarcodeScannerOptions$Builder

If that happens in your .NET-Android project, please follow these instructions:

  • Target the Android 9.0 (API 28) on the project Properties (Application and Manifest)

  • Add the NuGet package Xamarin.Google.MLKit.BarcodeScanning to the project

  • In your barcode.json configuration file, remove the barcodeFormatOptions attribute, so that the "barcodePlugin": { } attribute is empty

  • Erase the bin and obj folders and rebuild your project