com.brother.bms.iOSBindingLibrary 1.0.1001-testing

This is a prerelease version of com.brother.bms.iOSBindingLibrary.
dotnet add package com.brother.bms.iOSBindingLibrary --version 1.0.1001-testing
                    
NuGet\Install-Package com.brother.bms.iOSBindingLibrary -Version 1.0.1001-testing
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="com.brother.bms.iOSBindingLibrary" Version="1.0.1001-testing" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="com.brother.bms.iOSBindingLibrary" Version="1.0.1001-testing" />
                    
Directory.Packages.props
<PackageReference Include="com.brother.bms.iOSBindingLibrary" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add com.brother.bms.iOSBindingLibrary --version 1.0.1001-testing
                    
#r "nuget: com.brother.bms.iOSBindingLibrary, 1.0.1001-testing"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#addin nuget:?package=com.brother.bms.iOSBindingLibrary&version=1.0.1001-testing&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=com.brother.bms.iOSBindingLibrary&version=1.0.1001-testing&prerelease
                    
Install as a Cake Tool

Readme

What is this library?

This is a library that takes the Brother SDK for iOS and binds it in a library that users of .NET MAUI can consume

Requirements

Adjust the Import location

When you download the nuget package, the package will be imported to both iOS and Android.

<Project Sdk="Microsoft.NET.Sdk">
    ...
    ...
    
    <PackageReference Include="com.brother.bms.iOSBindingLibrary" Version="1.0.4091" />
    
    ...
    ...
</Project>

Move this PackageReference into a target specific tag.

<Project Sdk="Microsoft.NET.Sdk">
    ...
    
    ...
    <ItemGroup Condition="'$(TargetFramework)'=='net8.0-ios'">
        <PackageReference Include="com.brother.bms.iOSBindingLibrary" Version="1.0.4091" />
    </ItemGroup>
    ...
    ...
</Project>

Make Additions to your info.plist file

Bluetooth
<key>UISupportedExternalAccessoryProtocols</key>
<array>
    <string>Com.Brother.ptcbp</string>
</array>
<key>NSBluetoothPeripheralUsageDescription</key>
<string>$(PRODUCT_NAME) needs access to use Bluetooth</string>
<key>NSBluetoothAlwaysUsageDescription</key>
<string>$(PRODUCT_NAME) needs access to use Bluetooth</string>
WiFi
<key>NSBonjourServices</key>
<array>
    <string>_ipp._tcp</string>
    <string>_printer._tcp</string>
    <string>_pdl-datastream._tcp</string>
</array>
<key>NSLocalNetworkUsageDescription</key>
<string>This app requires access to the local network to discover and communicate with network devices.</string>

How to use this library

In your android code, import the library com.brother.sdk.lmprinter

public class iOSPrintingClass
{
    public iOSPrintingClass()
    {
        string PrintResult = string.Empty;
        string PDFPath = "path/to/your/pdf/file.pdf"; // Replace with your actual PDF file path

        BRLMChannel channel = SetupChannel("serialNumber"); // Replace with your printers actual serial number
        BRLMRJPrintSettings rjPrintSettings = new(BRLMPrinterModel.Rj4230b)
        {
            CustomPaperSize     = CreateCustomPaper(UtilityMethods.GetMediaSize(50)),
            ScaleMode           = BRLMPrintSettingsScaleMode.FitPageAspect,
            Halftone            = BRLMPrintSettingsHalftone.ErrorDiffusion,
            HAlignment          = BRLMPrintSettingsHorizontalAlignment.Center,
            VAlignment          = BRLMPrintSettingsVerticalAlignment.Center,
            ImageRotation       = BRLMPrintSettingsRotation.BRLMPrintSettingsRotationRotate0,
            HalftoneThreshold   = 128,
            NumCopies           = 1,
            SkipStatusCheck     = false
        };

        IBRLMPrintSettingsProtocol? validPrintSettings = ValidateSettings(rjPrintSettings);
        if (validPrintSettings is null)
        { /*  Handle the case where print settings are invalid */ }
        else
            PrintResult = await PrintMethod(channel, validPrintSettings, PDFPath); //NOTE: THIS SHOULD BE CALLED IN AN ASYNC METHOD

        //Do something with PrintResult
    }

    private static IBRLMPrintSettingsProtocol? ValidateSettings(IBRLMPrintSettingsProtocol printSettings)
    {
        BRLMValidatePrintSettingsReport validateReport = BRLMValidatePrintSettings.Validate(printSettings);
        if (validateReport.ErrorCount == 0)
            return printSettings;
        else return null;
    }
    public static async Task<string> PrintMethod(BRLMChannel channel, IBRLMPrintSettingsProtocol printSettings, string thingToPrint)
    {
        BRLMPrinterDriverGenerateResult driverResult = BRLMPrinterDriverGenerator.OpenChannel(channel);
        BRLMOpenChannelErrorCode driverError = driverResult.Error.Code;

        if (driverError != BRLMOpenChannelErrorCode.NoError)
        {
            string errorMessage = $"Error opening channel : {driverError}";
            return errorMessage;
        }

        BRLMPrinterDriver? printerDriver = driverResult.Driver;
        if (printerDriver == null)
        {
            string errorMessage = "Printer driver is null.";
            return errorMessage;
        }

        string result = await Task.Run(() =>
        {
            BRLMPrinterDriver? printerDriver = null;

            try
            {
                BRLMPrinterDriverGenerateResult driverResult = BRLMPrinterDriverGenerator.OpenChannel(channel);
                BRLMOpenChannelErrorCode driverError = driverResult.Error.Code;

                if (driverError != BRLMOpenChannelErrorCode.NoError)
                    return driverError.ToString();

                printerDriver = driverResult.Driver;
                if (printerDriver == null)
                    return PRINTER_DRIVER_NULL;

                var url = new NSUrl(thingToPrint);
                if (url == null || url.AbsoluteString == string.Empty)
                    return "Invalid PDF file path";

                BRLMPrintError printResult = printerDriver.PrintPDFWithURL(url, printSettings);

                Debug.WriteLine($"PDFPrint Result: {printResult.ErrorDescription}");
                return $"{printResult.Code}\n{printResult.ErrorDescription}";
            }
            catch (Exception ex)
            {
                return $"SDK Exception (inner): {ex}";
            }
            finally
            {
                printerDriver?.CloseChannel();
            }
        });
        return result;
    }
    public static BRLMChannel SetupChannel(string serialNumber)
    {
        var channel = new BRLMChannel();
        channel.initWithBluetoothSerialNumber(serialNumber);
        return channel;
    }

}

Resources

Brother Print SDK Manual

https://support.brother.com/g/s/es/htmldoc/mobilesdk/index.html

BMS Website

https://brothermobilesolutions.com/

Contact Information

E-mail us: bmsdevsupport@brother.com

SDK Version

This library binding is completed against SDK version 4.12.0

Product Compatible and additional computed target framework versions.
.NET net8.0-ios18.0 is compatible.  net9.0-ios was computed.  net9.0-ios18.0 is compatible.  net10.0-ios was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net8.0-ios18.0

    • No dependencies.
  • net9.0-ios18.0

    • No dependencies.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.1001-testing 1 6/5/2025

releaseNotes.md