Error Writing to Connection on iOS

//Where ChosenPrinter implements IDiscoveredPrinter
//Error occurs attempting to invoke Connection.Write.
//My connection properties just prior to writing are attached in the image below.

connection = ChoosenPrinter.Connection;
if (!connection.IsConnected) connection.Open();
PrinterLanguage printerLanguage = PrinterLanguage.ZPL;
IZebraPrinter printer = ZebraPrinterFactory.Current.GetInstance(printerLanguage, connection);
/*if ((!CheckPrinterLanguage(connection)) || (!PreCheckPrinterStatus(printer)))
{

return;
}*/
printer.Connection = connection;
if (Device.RuntimePlatform == Device.iOS)
{
printer.Connection = connection;
//string printerSettings = m_session.AppSpec.GetValue<string>("ZebraPrinterVarSettings", "");
string printerSettings = "! U1 setvar \"device.languages\" \"zpl\"+! U1 setvar \"media.type\" \"journal\"";
string[] vars = printerSettings.Split('+);
if (vars != null && vars.Length > 0)
{
foreach (string var in vars)
{
connection.Write(Encoding.UTF8.GetBytes(var + "\r\n"));
}
//connection.Write(Encoding.UTF8.GetBytes("! U1 setvar \"device.languages\" \"zpl\"\r\n"));
//connection.Write(Encoding.UTF8.GetBytes("! U1 setvar \"media.type\" \"journal\"\r\n"));
}
}

Attachments: 
Steven Si
For iOS, we need to add com

For iOS, we need to add com.zebra.rawport to the "supported external accessory protocols" in the info.plist in order to allow the app to connect to Zebra printer over Bluetooth.

Vote: 
Vote up!
Vote down!

Points: 0

You voted ‘up’


Log in to post comments