3 Replies Latest reply on May 19, 2017 12:49 PM by James Landers

    Print on imz320 with ios SDK (swift)

    Cagatay Yıldırım

      Hi,

       

      we want to add zebra sdk our IOS and Android apps.Android was easy it works great.But there is problems in IOS swift.(i use latest sdk 1.4.948)

       

      i added libzZSDK_API.a , ExternalAccessory.framework,Quartzcore,UIKIT,foundation,coregraphics  and also

      i changed info.plist (Required background modes and Supported external accessory ...) i can see these on capabilities .my code block

        let connection:MfiBtPrinterConnection = MfiBtPrinterConnection(serialNumber: serial)

       

              connection.open()

              if(connection.isConnected())

              {

                         do {

                          //    try SGD.SET("bluetooth.page_scan_window", withValue: "60", andWithPrinterConnection: connection)

                      let  printer   =  try ZebraPrinterFactory.getInstance(connection)

                      let lang =  printer.getPrinterControlLanguage()

                      if(lang != PRINTER_LANGUAGE_CPCL){

                          let tool = printer.getToolsUtil()

                          try  tool.sendCommand(dosya)

                      }             

                  } catch {

                      print(error)

                  }

       

                     connection.close()

              }

      this gives error "Unable to determine printer language" at "let  printer   =  try ZebraPrinterFactory.getInstance(connection)"

      when i chance this with "let  printer   =  try ZebraPrinterFactory.getInstance(connection, withPrinterLanguage: PRINTER_LANGUAGE_ZPL)" it works but after this

       

      it gives error "Error writing to connection" at " try  tool.sendCommand(dosya)"

        • Re: Print on imz320 with ios SDK (swift)
          Cagatay Yıldırım

          Now i tried with objective-C in a few ways and there was same error

           

           

          ExternalAccessory-329.10.2/EAOutputStream.m:-[EAOutputStream write:maxLength:] - 283 failed to write because stream does not have space available

           

          rwest@@

           

          NSString *yazici = @"XXXXJ143901964";

          id<ZebraPrinterConnection, NSObject> connection = nil;

          connection = [[MfiBtPrinterConnection alloc] initWithSerialNumber:yazici] ;

          BOOL didOpen = [connection open];

          if(didOpen == YES) {

               // NSError *error = nil;

          // id<ZebraPrinter,NSObject> printer = [ZebraPrinterFactory getInstance:connection withPrinterLanguage:PRINTER_LANGUAGE_ZPL ];

          // if(printer != nil) { // PrinterLanguage language = [printer getPrinterControlLanguage];

          NSString *testLabel;

          testLabel = @"^XA^FO17,16^GB379,371,8^FS^FT65,255^A0N,135,134^FDTEST^FS^XZ";

          NSData *data = [NSData dataWithBytes:[testLabel UTF8String] length:[testLabel length]];

          [connection write:data error:nil];

          // [[printer getToolsUtil] sendCommand:testLabel error:nil ];

          // } // } }

          • Re: Print on imz320 with ios SDK (swift)
            James Landers

            Cagatay,

             

            I too am trying to print to one of the Zebra remote printers, however I cannot find any clear swift examples of how to do this.  Would you be able to share example code on how you connected to and printed to your printer.  Fairly new to swift, so any help is appreciated.

             

            Thank you