Receipt Printing

Liquid Core API supports interfacing with external receipt printers in order to print items. Currently, Liquid works with the Zebra IMZ mobile printers. Much like many other things in the Liquid Core API, there are two major components to setting up printing: code and configuration.

Configuration

The receipt is printed based on the configuration item PrintConfig. Each field represents a section in the configuration. Use the diagram below see how each field is mapped.

Diagram Needed

*Notes: You'll notice in the configuration that the cart item is never referenced in the context, this is because by default, the print object requires the existence of a cart object. The section below will explain the default behavior.*

Code Integration

The print life cycle is completely taken care of when integration with LDKPrinterManagerViewController. To use, simply instantiate a new instance of the class, and provide the two required variables. Then present the new view controller modally.

self.printerManager = [[LDKPrinterManagerViewController alloc] init];    
self.printerManager.cart = //The Cart to print
self.printerManager.printerProfile = //The Print Config Item

UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:self.printerManager];
navController.modalPresentationStyle = UIModalPresentationFormSheet;
[self presentViewController:navController animated:YES completion:nil];

LDKPrinterManagerViewController shows all available printers in a UITableView. When you select on the printer you wish to connected to, the connection status will update automatically to inform the user when it's ready for use. Then simply pres the Print button when to get the receipt. When selecting any zebra supported printer, the configuration will automaticlaly linked based on the printerConfigId, which in this case must be the string zebra.

It is possible to write your own Printer Manager class. For more information see the LDKPrinter API.

Hooking Up the Printer

Step 1 - Enabling External Accessory Interfacing To App ID

When creating an iOS app and connecting to a wireless accessory, you must use a physical iOS device. When creating the app ID, Wireless Accessory Configuration must be enabled. Remember that any update to the app ID requires regeneration of the Provisioning Profile.

Step 2 - Adding XCode Entitlements

Open up your main XCode.proj file, and select Capabilities section. (Select the main target, second tab from the left). Scroll all the way to the end and enable Wireless Accessory Configuration.

Since we are working with Zebra printers, there's 1 more step involved. Go to the projects Info.plist, and add an entry for supported external accessory.

Alternatively, you can always add the following code:

    <key>UISupportedExternalAccessoryProtocols</key>
    <array>
        <string>com.zebra.rawport</string>

You can now deploy the application on your device and connect to your external accessory and start printing.

results matching ""

    No results matching ""