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:
-
Create your Development Certificate
-
Download the certificate and install it on your Mac host
-
Create an App Identifier for your specific Bundle ID, with
NFC Tag Reading capability
-
Create a Provisioning Profile linked with your previously created Certificate and App Identifier
-
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:
-
Open the examples app solution in Visual Studio
-
Right-click in the
Anyline.Examples.MAUI
project (not the solution) > Properties -
In the
iOS Bundle Signing
tab, find theCustom Entitlements
field -
Search for the file
Entitlements.plist
, located in the root of the iOS project -
In
Signing Identity
andProvisioning Profile
select the certificate and profile created in the Apple developer portal -
Save the changes
Error Messages
|
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:
-
Add to your
AndroidManifest.xml
file the NFC Permission:<uses-permission android:name="android.permission.NFC" />
-
Add to your
AndroidManifest.xml
file the NFC Feature:<uses-feature android:name="android.hardware.nfc" android:required="false" />
-
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
-
Use a standard NFCScanningViewRenderer for scanning the MRZ data
-
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