Skip to content

StarXpand SDK for iOS is a software development kit for supporting application development for Star Micronics devices.

License

Notifications You must be signed in to change notification settings

star-micronics/StarXpand-SDK-iOS

Repository files navigation

StarXpand SDK for iOS

StarXpand SDK for iOS is a software development kit for supporting application development for Star Micronics devices.

This software development kit provides the StarIO10 framework (StarIO10.xcframework) as a framework to control the Star Micronics devices.

In accordance with Apple's guidelines, StarIO10 V2.6.1 or later includes a privacy manifest file. Please see here for the Manifest file. However, StarIO10 does not use the Required Reason API from the first release. (As of January 29, 2024)

Documentation

Please refer here for StarXpand SDK documentation.

Documentation includes an overview of the SDK, how to build a sample application, how to use the API, and a API reference.

Requirements

Language Language Version Platform OS Version Arch
Swift 5 iOS iOS 13.0 or later Device: arm64
Simulator: arm64, x86_64

Installation

1. Add the StarIO10 framework to your project

In order to integrate the StarIO10 framework into your iOS application, Use Swift Package Manager.

  1. In Xcode, select File menu > Add Packages....
  2. Enter https://github.com/star-micronics/StarXpand-SDK-iOS in the URL input field.
  3. Select StarXpand-SDK-iOS and press Add Package button.

For more information on how to integrate Swift Package, please refer to the following URL.

https://developer.apple.com/documentation/swift_packages/adding_package_dependencies_to_your_app

2. Preliminary Procedures

Some settings and approvals are required depending on the printer interface.
Please check the table below and take action.

Interface of the printer Necessary actions
Bluetooth 2.1. & 2.2. & 2.4.
Bluetooth Low Energy 2.2.
Ethernet (iOS14 or later) 2.3.
Lightning USB 2.1. & 2.4.

2.1. Set Supported external accessory protocols

  1. Click on the information property list file (default : “Info.plist").
  2. Add the Supported external accessory protocols Key.
  3. Click the triangle of this key and set the value for the “Item 0" to jp.star-m.starpro.

⚠️ If you do not use the printer concerned, do not configure this setting.

2.2. Set Bluetooth Always Usage Description and Bluetooth Peripheral Usage Description

  1. Click on the information property list file (default : “Info.plist").
  2. Add the Privacy - Bluetooth Always Usage Description Key.
  3. If you set Deployment Target to iOS12, add the Privacy - Bluetooth Peripheral Usage Description Key.
  4. Set the reason for using Bluetooth in Value (e.g. Use Bluetooth for communication with the printer.)
  5. When communicating with the Bluetooth printer on iOS 13 or later, an alert requesting permission to access Bluetooth is displayed. The string set in Value is displayed in the alert as the reason for using Bluetooth.

For more information, please refer to the following URL.

https://developer.apple.com/documentation/bundleresources/information_property_list/nsbluetoothperipheralusagedescription

2.3. Set Local Network Usage Description

  1. Click on the information property list file (default : “Info.plist").
  2. Add the Privacy - Local Network Usage Description Key.
  3. Set the reason for using Local Network in Value (e.g. Use Local Network for communication with the printer or discovery the printers.)
  4. When communicating with the Ethernet printer on iOS 14 or later, an alert requesting permission to access Local Network is displayed. The string set in Value is displayed in the alert as the reason for using Local Network.

2.4. Apple Approval Process for STAR MFi Applications

In order to offer your application that communicates a MFi certified printer on the Apple iTunes App Store, your application needs to be approved by the Apple MFi program before you submit it to the Apple iTunes App Store. Please follow the steps described in the URL below to obtain the app approval. This procedure must be completed before the app is reviewed by Apple.

https://star-m.jp/eng/products/s_print/apple_app_mfi.html

⚠️ In case of a Bluetooth Low Energy printer, you do not need to obtain this app approval.

Examples

StarXpand SDK includes an example application that can be used in combination with the printer to check its operation. Please use it in conjunction with the explanations of each function in the linked pages.

The sample code and printed result images are also available here.

  • Sample to create print layouts for receipts and labels for each type of business
  • Sample to generate receipt images from text data

⚠️ Some printer models may not be able to print some samples. Please adjust the layout accordingly when using this samples.

Get printer status

func getStatus() {
    // Specify your printer connection settings.
    let starConnectionSettings = StarConnectionSettings(interfaceType: .lan,
                                                        identifier: "00:11:62:00:00:00")
    
    let printer = StarPrinter(starConnectionSettings)
    
    Task {
        do {
            // Connect to the printer.
            try await printer.open()
            defer {
                Task {
                    // Disconnect from the printer.
                    await printer.close()
                }
            }

            // Get printer status.
            let status = try await printer.getStatus()
            print(status)
        } catch let error {
            // Error.
            print(error)
        }
    }
}

Monitor printer

var printer: StarPrinter?

func monitor() async {
    // Specify your printer connection settings.
    let settings = StarConnectionSettings(interfaceType: .lan,
                                          identifier: "00:11:62:00:00:00")
    printer = StarPrinter(settings)
    
    guard let printer = printer else {
        return
    }
    
    printer.printerDelegate = self
    printer.drawerDelegate = self
    printer.inputDeviceDelegate = self
    printer.displayDelegate = self
    
    Task {
        do {
            // Connect to the printer.
            try await printer.open()
        } catch let error {
            // Error.
            print(error)
        }
    }
}

// Callback for printer state changed.

func printerIsReady(_ printer: StarPrinter) {
    print("Printer: Ready")
}

func drawer(printer: StarPrinter, didSwitch openCloseSignal: Bool) {
    print("Drawer: Open Close Signal Switched: \(openCloseSignal)")
}

func inputDevice(printer: StarPrinter, didReceive data: Data) {
    print("Input Device: DataReceived \(NSData(data: data))")
}

func displayDidConnect(printer: StarPrinter) {
    print("Display: Connected")
}

// ...
// Please refer to document for other callback.

Copyright

Copyright 2022 Star Micronics Co., Ltd. All rights reserved.

About

StarXpand SDK for iOS is a software development kit for supporting application development for Star Micronics devices.

Resources

License

Stars

Watchers

Forks