Table of Contents

.NET MAUI

Follow these simple steps below to integrate NurApi with your .NET MAUI project:

Step 1: Declare permissions

Before we can use functionality such as the device discovery, we have to declare some permissions first.

Note
  • The following permissions are required to identify RFID readers connected via USB or Bluetooth Low Energy.
  • Locate your AndroidManifest.xml at the Platforms/Android folder within your project and add the following permissions to the file:
	<!-- Request legacy Bluetooth permissions on older devices. -->
	<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
	<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
	<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
	<uses-permission android:name="android.permission.BLUETOOTH_PRIVILEGED" />
	<uses-permission android:name="android.permission.BLUETOOTH" />
	<uses-permission android:name="android.permission.BLUETOOTH_ADVERTISE" />
	<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
	<uses-permission android:name="android.permission.BLUETOOTH_SCAN" />
	<uses-permission android:name="android.permission.BLUETOOTH_CONNECT" />
    <uses-feature android:name="android.hardware.bluetooth_le" android:required="true" />
	<uses-feature android:name="android.hardware.usb.host" android:required="true" />
	<uses-permission android:name="android.permission.USB_PERMISSION" />

Step 2: Installing NurApi & Support libraries

Next, you'll need to install the following NuGet packages. You can easily find and install them using the NuGet package manager in Visual Studio.

Note

Adding the packages at the Solution level allows you to add it to every target framework correctly in one step.

After the NuGet packages are installed, it should resemble the example below:

Example

Step 3: Initializing the Support libraries

In .NET MAUI we can use a simple preprocessor compiler directive to initialize the appropriate support library for each platform. Locate your MauiProgram.cs and find the function CreateMauiApp(). Place this inside the function:

#if __ANDROID__
            NurApiDotNet.Android.Support.Init(
            Microsoft.Maui.ApplicationModel.Platform.AppContext);
#elif __IOS__ || __MACCATALYST__
              NurApiDotNet.iOS.Support.Init();
#endif

When you are done, your CreateMauiApp() should resemble the following:

public static MauiApp CreateMauiApp()
        {
#if __ANDROID__
            NurApiDotNet.Android.Support.Init(
            Microsoft.Maui.ApplicationModel.Platform.AppContext);
#elif __IOS__ || __MACCATALYST__ 
              NurApiDotNet.iOS.Support.Init();
#endif
            var builder = MauiApp.CreateBuilder();
            builder
                .UseMauiApp<App>()
                .ConfigureFonts(fonts =>
                {
                    fonts.AddFont("OpenSans-Regular.ttf", "OpenSansRegular");
                    fonts.AddFont("OpenSans-Semibold.ttf", "OpenSansSemibold");
                });

#if DEBUG
            builder.Logging.AddDebug();
#endif

            return builder.Build();
        }

Ready to Utilize NurApi

Congratulations! You're now fully equipped to leverage NurApi.