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.


Getting Started

  • Add the following dependency to your pubspec.yaml: brady_flutter_plugin: ^2.0.0+2
  • To demonstrate the basic functionalities of the Brady SDK Flutter Plugin, copy and paste the main.dart under the "example" tab into a fresh Flutter project.
  • For the example app to work, you must provide an image or template (.BWT file) to print. Add the following to the pubspec.yaml: under the "flutter" block:
assets:
   - assets/
  • Now, at the root of your project, create a folder named "assets" and place all images and templates (.BWT files) here.

Android Setup

  • It is recommended to change minSdkVersion in your app/build.gradle to 26.
  • Flutter applications will still build if minSdkVersion is lower than 26. However the SDK will not communicate with printers if the mobile device is less than 26 (Android 8).
  • When developing a Flutter application for Android, the "buildTypes" block in the "app/build.gradle" must be changed to the following:
buildTypes {
    release {
        //The following two lines ensure that no third-party library classes get ignored at compile-time.
        //This is crucial because the Brady Android SDK depends on these classes to make a successful connection.
        shrinkResources false
        minifyEnabled false
        signingConfig signingConfigs.debug
   }
}

iOS Setup

  • It is recommended to use the widely used Flutter Permissions library to handle permissions.
  • Add the following to your Flutter app's pubspec.yaml: "permission_handler: ^11.3.1"
  • Add the following permissions to your Podfile's post_install:
post_install do |installer|
  installer.pods_project.targets.each do |target|
    flutter_additional_ios_build_settings(target)
    target.build_configurations.each do |config|
      # You can remove unused permissions here
      # for more information:
      https://github.com/BaseflowIT/flutter-permission-handler/blob/master/permission_handle
      r/ios/Classes/PermissionHandlerEnums.h
      # e.g. when you don't need camera permission, just add 'PERMISSION_CAMERA=0'
      config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] ||= [
        '$(inherited)',
        ## dart: PermissionGroup.calendar
        'PERMISSION_EVENTS=0',
        ## dart: PermissionGroup.reminders
        'PERMISSION_REMINDERS=0',
        ## dart: PermissionGroup.contacts
        'PERMISSION_CONTACTS=0',
        ## dart: PermissionGroup.camera
        'PERMISSION_CAMERA=1',
        ## dart: PermissionGroup.microphone
        'PERMISSION_MICROPHONE=0',
        ## dart: PermissionGroup.speech
        'PERMISSION_SPEECH_RECOGNIZER=0',
        ## dart: PermissionGroup.photos
        'PERMISSION_PHOTOS=0',
        ## dart: [PermissionGroup.location, PermissionGroup.locationAlways,
        PermissionGroup.locationWhenInUse]
        'PERMISSION_LOCATION=1',
        'PERMISSION_LOCATION_ALWAYS=1',
        'PERMISSION_LOCATION_WHENINUSE=1',
        ‹
        ## dart: PermissionGroup.notification
        'PERMISSION_NOTIFICATIONS=0',
        ## dart: PermissionGroup.mediaLibrary
        'PERMISSION_MEDIA_LIBRARY=0',
        ## dart: PermissionGroup.sensors
        'PERMISSION_SENSORS=0',
        ## dart: PermissionGroup.bluetooth
        'PERMISSION_BLUETOOTH=1',
        ## dart: PermissionGroup.appTrackingTransparency
        'PERMISSION_APP_TRACKING_TRANSPARENCY=0',
        ## dart: PermissionGroup.criticalAlerts
        'PERMISSION_CRITICAL_ALERTS=0',
      ]
    end
  end
end
  • Add the following permissions to your info.plist:
<key>NSBluetoothAlwaysUsageDescription</key>
<string>To find nearby printers.</string>
<key>NSBluetoothPeripheralUsageDescription</key>
<string>To find nearby printers.</string>
<key>NSLocalNetworkUsageDescription</key>
<string>To find nearby printers.</string>
<key>NSLocationUsageDescription</key>
<string>To find and connect to nearby printers</string>
<key>NSLocationAlwaysAndWhenInUseUsageDescription</key>
<string>To find and connect to nearby printers</string>
<key>NSLocationWhenInUseUsageDescription</key>
<string>To find and connect to nearby printers</string>
<key>NSBonjourServices</key>
    <array>
        <string>_pdl-datastream._tcp.</string>
    </array>
  • Show a permissions request to your user with the following code:
Map<Permission, PermissionStatus> statuses = await [
    Permission.bluetooth,
    Permission.bluetoothConnect,
    Permission.bluetoothScan,
    Permission.nearbyWifiDevices,
    Permission.locationWhenInUse
].request();

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...