Flutter

Flutter is an open source framework by Google that allows developers to use the Dart programming language to generically call into iOS, Android, MacOS, Windows, and Linux code. pub.dev is an online database of packages and plugins that can be used by anyone. We have published our Flutter Plugin for the Brady SDK here.

After navigating to the Flutter plugin online, follow the installation tutorial under the "installing" tab.

Additionally, you must add the following lines of code to the "buildTypes" block in your Flutter app's "app/build.gradle". This is because the Android SDK, depends on some third-party libraries that will not be included if the app is minified.

While adding the plugin to a Flutter app, we occasionally ran into the following error on the iOS side:

Although the cause is unknown, the image below provides a solution when the configuration of the Runner project is changed to what is shown in the image below:


Get Started

Android Prerequisites:

  • minAndroidSdk in your app's Android project should be at least 23.
  • Gradle version should be upgraded to 7.6 at least.
  • Gradle.build.tool version should be upgraded to 7.4.2 at least.
  • Kotlin version should be upgraded to 1.8.21 at least.
  • If using Flutter's recommended permission_handler plugin, you must add the following permission requests:
    • Permission.bluetooth,
    • Permission.bluetoothConnect,
    • Permission.bluetoothScan,
    • Permission.locationWhenInUse
    • Permission.nearbyWifiDevices (if you want your app to support Wi-Fi connection)

iOS Prerequisites:

  • Must have Cocoapods installed on your machine.
  • Must include the line "platform :ios, '15.0'" (15.0 at least) in the Podfile of your app.
  • Must run the command "pod install" to retrieve the dependency for the brady_flutter_plugin.
  • Must add the following Permissions to your app's info.plist:
    • "Privacy - Bluetooth Peripheral Usage Description"
    • "Privacy - Bluetooth Always Usage Description"
    • "Privacy - Local Network Usage Description"
    • "Bonjour Services"
      • Item 0 -> _pdl-datastream._tcp.

If you are adding the Plugin to a fresh Flutter app for testing purposes, use the following steps to get started:

  • Copy the "main.dart" file provided in the README and paste it in your fresh Flutter app.
  • Replace "M611-PGM6112301301020" with your printer's name in the "connect()" function.
  • Download this test template to use.
  • Create an "assets" folder in the root of your Flutter app.
  • Drop the template in the folder.
  • Navigate to your pubspec.yaml file and add the following code:
assets:
    - assets/flutter_multi_label.BWT

Xamarin

Xamarin is an open source framework owned by Microsoft to allow developers to use the C# programming language to generically call into code from multiple operating systems. Developers are able to publish libraries in the form of NuGet packages to nuget.org to be used within Xamarin applications.

You can get the current version of the Brady SDK Xamarin Bindings by simply searching BradyCorp.Xamarin.SDK in your Visual Studio project under the "Manage NuGet Packages..." menu. Alternatively, you can view the package and its metadata on nuget.org at https://www.nuget.org/packages/BradyCorp.Xamarin.SDK.

IMPORTANT: The largest difference between integrating the Xamarin Binding and the Flutter Binding is that the Xamarin Binding must be implemented for both iOS and Android separately in both native projects. This is due to different constructors for each platform and alternative threading methods that need to be dealt with differently.

IMPORTANT: Usable templates must be embedded in the Xamarin app's Resources and marked as an "AndroidResource" in the files "build properties". Due to a data conversion issue between languages in the back-end, we do not support users retrieving files from their device's file system at runtime.


Prerequisites


Xamarin.Android Version: Android 12

Xamarin.Android Permissions:

  • AccessCoarseLocation
  • AccessFineLocation
  • Bluetooth
  • BluetoothScan
  • BluetoothConnect

Xamarin.iOS Version: iOS 15

Xamarin.iOS Permissions:

In the iOS specific project, right-click the "Info.plist" in the Solution Explorer and select "View Code". Copy and paste the following within the "dict" tag:

<key>NSBluetoothPeripheralUsageDescription</key>
<string>Requires Bluetooth to discover nearby devices.</string>
<key>NSBluetoothAlwaysUsageDescription</key>
<string>Requires Bluetooth to discover nearby devices.</string>
<key>NSBonjourServices</key>
<array>
    <string>_pdl-datastream._tcp.</string>
</array>

The Xamarin.Android API is nearly identical to the Base Android SDK. However the Xamarin.iOS API is nearly identical to the Flutter API. You can find all of this documentation on this site via the the navigation on the left.

For both iOS and Android, you must call the .connectToPrinter(String) and .print() methods from a different thread. That might look like this:

Thread connectThread = new Thread(() =>
{
    bool status = BradySdk.connectToPrinter(printer).Result;
    if (status)
    {
       Debug.WriteLine("Connection Status: " + status);
    }
});
connectThread.Start();

Refer to the API page for documentation on the different constructors.

.NET MAUI

.NET MAUI is an open source framework owned by Microsoft to allow developers to use the C# programming language to generically call into code from multiple operating systems. Developers are able to publish libraries in the form of NuGet packages to nuget.org to be used within .NET MAUI applications.

You can get the current version of the Brady SDK MAUI Bindings by simply searching BradyCorp.Maui.SDK in your Visual Studio project under the "Manage NuGet Packages..." menu. Alternatively, you can view the package and its metadata on nuget.org at https://www.nuget.org/packages/BradyCorp.Maui.SDK.


Prerequisites


The .NET MAUI bindings are nearly identical to the Xamarin bindings in terms of prerequisites and setup. The differences are noted below:

  • Only supported in applications with .NET 8.0 and newer.

  • Must add the following statement to your MAUI app's .csproj file. This statement is iOS specific and its purpose is to allow Objective-C code to translate properly into C# code inside the binding. Think of this as a permission.

<PropertyGroup>
    <MtouchExtraArgs>--require-pinvoke-wrappers=true</MtouchExtraArgs>
</PropertyGroup>
  • Next, you must add this package to both the iOS and Android native projects if you are using a MAUI application. To access the library's API, use the following using statements:
- Android: Implementation identical to the native Android SDK [here](https://sdk.bradyid.com/printer_discovery_android/)
- iOS: "using BradySdkMauiIOSWrapper"

React Native

React Native is an open source framework owned by Microsoft to allow developers to use JavaScript and TypeScript to generically call into code from multiple operating systems. Developers are able to publish libraries in the form of npm packages to npmjs.com to be used within React Native applications.

Currently in development...