IDTech Windows SDK Guide  3.2.4.393
API reference for Visual Studio .Net
Using SDK on iOS/Android with MAUI

The IDTech SDK can be use on iOS and Android platform when coding with MAUI in Visual Studio.

Android/IOS sample code can be found here:
https://atlassian.idtechproducts.com/confluence/download/attachments/30479625/MAUI_SDKuDemo.zip?api=v2

Once you have established your MAUI project, right-click on your project and select "Manage NuGet Packages..." import IDTech.Maui.Comm from NuGet. Note, this will automatically import the other libraries, including the iOS and Android binding libraries, and IDTechSDK.dll. There is no need to separately import IDTechSDK_STD from NuGet

NOTE: You need to save your project as a solution (.sln) before you will be able to manage NuGet packages.

Setting Up iOS Platform Bindings

In the Main routine in Program.cs in the Platforms/iOS, execute IDTech.Maui.Comm.IDTechBinding.Init(); BEFORE the app delegate.

public class Program
{
// This is the main entry point of the application.
static void Main(string[] args)
{
IDTech.Maui.Comm.IDTechBinding.Init();
// if you want to use a different Application Delegate class from "AppDelegate"
// you can specify it here.
UIApplication.Main(args, null, typeof(AppDelegate));
}
}

Add permissions to your info.plist

If you are planning on using the lightning connector and External Accessory Protocol, include the protocol string for the product(s) you would like to use. NOTE: Your app will need approval to use any listed devices before publishing to App Store, so only include devices you plan to use. If you don't plan on using any of the Lightning Connector devices, exclude this key from your .plist

    VP3350 = com.idtechproducts.neo
    BTMag = com.idtechproducts.BTMag
    BTPay = com.idtechproducts.BTPay 200
    iMag = com.idtechproducts.reader
<key>UISupportedExternalAccessoryProtocols</key>
<array>
<string>com.idtechproducts.neo</string>
<string>com.idtechproducts.reader</string>
<string>com.idtechproducts.BTPay 200</string>
<string>com.idtechproducts.BTMag</string>
</array>

If you are planning on using BLE devices, add the following:

<key>NSBluetoothAlwaysUsageDescription</key>
<string>Captures Payment Information</string>
<key>NSBluetoothPeripheralUsageDescription</key>
<string>Captures Payment Information</string>

If you are planning on using Audio Jack devices, add the following:

<key>NSMicrophoneUsageDescription</key>
<string>Captures Payment Information</string>

Setting Up Android Platform Bindings

In the MainActivity onCreate routine for Android, execute IDTech.Maui.Comm.IDTechBinding.Init(this) BEFORE base.OnCreate.

In the MainActivity onCreate routine for Android, set this.RequestPermissions AFTER LoadApplication.

After the RequestPermission are established, enable the USB drivers in IDTechBinding by execcuting IDTech.Maui.Comm.IDTechBinding.enableUSB();

protected override void OnCreate(Bundle savedInstanceState)
{
IDTech.Maui.Comm.IDTechBinding.Init(this);
SharedController = this;
base.OnCreate(savedInstanceState);
Platform.Init(this, savedInstanceState);
this.RequestPermissions(new[]
{
Manifest.Permission.AccessCoarseLocation,
Manifest.Permission.AccessFineLocation,
Manifest.Permission.AccessNetworkState,
Manifest.Permission.BluetoothPrivileged,
Manifest.Permission.Bluetooth,
Manifest.Permission.BluetoothAdmin,
Manifest.Permission.ModifyAudioSettings,
Manifest.Permission.RecordAudio
}, 0);
IDTech.Maui.Comm.IDTechBinding.enableUSB();
}

In your manifest of your Android Project, set the required permissions. You can set the manifest by editing Android Project Options ->Android Application->Required Permissions and select the following

- AccessCoarseLocation,
- AccessFineLocation,
- AccessNetworkState,
- BluetoothPrivileged,
- Bluetooth,
- BluetoothAdmin,
- ModifyAudioSettings,
- RecordAudio

Setting Up Main (Shared) Platform Bindings

IDTech SDK was imported when you imported the IDTech.Maui.Comm library into the main project.

Other than special considerations for connecting to the devices on the mobile platform (specified below), follow the standard project development procedures by references in the other sections of this help document and also Windows Forms IDTech SDK uDemo source code "dot NET SDK Demo Source Code.zip". Standard development consists of setting the callback, and then executing API commands using a shared controller. The project page with these files can be found at: https://atlassian.idtechproducts.com/confluence/display/KB/Universal+Library+for+Visual+Studio+-+Home

Communicating with Devices

There are four groups of devices that can be used on Android: Bluetooth Low Energy, Auido Jack, USB, Audio Jack and Serial

There are three groups of devices that can be used on iOS: Bluetooth Low Energy, Lightning Connector, and Audio Jack

Bluetooth Low Energy (Android and iOS).
This includes the VP3300, and NEOII devices, such as VP3310, VP3320, VP3350, and VP3600.

You connect to a BLE device using the following method:

IDT_Device.startBLEScan(IDT_DEVICE_Types type, string name);

The first parameter is the device type. This can have one of three possible values: IDT_DEVICE_Types.IDT_DEVICE_VP3300 - VP3300, VP8300 IDT_DEVICE_Types.IDT_DEVICE_NEO2 - VP3600, VP3320, VP3350 (VP6800 BLE is currently not supported) IDT_DEVICE_Types.IDT_DEVICE_NONE - scan for name when no name provided

The second parameter is the device name that you would like to connect to.

If you don't specify a name (and set device type to IDT_DEVICE_Types.IDT_DEVICE_NONE), the SDK will scan the area and return a list of all found names. You can then use one of those names to attempt to connect to that device. When the SDK finishes scanning the area (2-3 seconds), it will return a callback DeviceState.BTListReady. You can then execute IDT_Device.getBLEDeviceList() to retrieve the list of device names found in the vicinity.

case DeviceState.BTListReady:
List<string> btDevices = null;
btDevices = IDT_Device.getBLEDeviceList();
displayBLEDevices(btDevices);
break;
USB (Android Only).
USB device detection is automatic. The SDK callback will inform when devices are attached or detached from the system. No special considerations or coding needed
Serial (Android Only).
Using a Serial to USB adapter, you can attempt to connect to a serial device with the following method:
IDT_Device.useSerialAdapter(IDT_DEVICE_Types type, int baud);

The first parameter is the type of device you would like to connect to. If you would like to connect to a MiniSmartII, you would pass IDT_DEVICE_Types.IDT_DEVICE_MINISMARTII

The second parameter is the baud rate. If you pass a value of 0, it will use the factory default baud rate. Otherwise, if the baud rate was changed, you specify it here (example 9600)

Audio Jack (Android/iOS).
For Audio Jack, you first need to tell the SDK which device it need to configure the audio drivers for, and then monitor the Headphone Jack plug/unplug events, and when a plug event happens, send a command to connect to the audio jack reader.

Here are the available devices to configure the SDK for the correct model audio jack product

IDT_Device.startAudioJack(IDT_DEVICE_Types.IDT_DEVICE_VP3300);
IDT_Device.startAudioJack(IDT_DEVICE_Types.IDT_DEVICE_UNIPAYI_V);
IDT_Device.startAudioJack(IDT_DEVICE_Types.IDT_DEVICE_UNIPAY);
IDT_Device.startAudioJack(IDT_DEVICE_Types.IDT_DEVICE_UNIMAG);
IDT_Device.startAudioJack(IDT_DEVICE_Types.IDT_DEVICE_UNIMAG_PRO);

Then when a plug insertion event is detected, you power up the device:

case DeviceState.PlugInserted:
appendMessageToResults("Plug Inserted");
IDT_Device.connectToAudioReader();
//When using audio jack devices, notification of a device insertion will appear here
break;
External Accessory (iOS Only).
External Accessory devices are automatically detected
Additional Callbacks.
There are some additional DeviceState callback event on applicable to Audio Jack connections.

There is a DeviceMessage callback. These are device message returned from various audio jack products. Messages such as "POWERING UNIPAY" and "PLEASE SWIPE"

case DeviceState.DeviceMessage:
//When iOS SDK needs to send out SDK messages, it will appear here
if (data != null)
{
string message = Encoding.UTF8.GetString(data, 0, data.Length);
appendMessageToResults(message);
}

The UniPay may have ICC messages

case DeviceState.UniPayICC:
appendMessageToResults("UniPay ICC Event: " + data[0].ToString("x2"));
//When using UniPay, device notifications (card inserted, card removed) will appear here
break;