Discover Printers:

Before we attempt to discover nearby printers, we must request the user to approve the required permissions:

Requesting Permissions:

(Reference the Prerequisites page for the iOS SDK)

  • This should prompt the user only on the initial opening of the application.
    • If the user does not allow permissions when prompted, they can always go into the settings app to allow them later. However, the user will never be able to discover printers without approving these permissions.

Implementing Discovery:

  • Create a new PrinterDiscovery object:
var printerDiscovery: PrinterDiscovery = PrinterDiscoveryFactory.getPrinterDiscovery(listeners: [PrinterDiscoveryListener])
  • Start discovering nearby printers:
    • PrinterDiscoveryListener must be implemented in the UI's class where you will store the discovered printer objects.
      • This will force you to add the printerDiscovered method that you can implement like:
public func printerDiscovered(discoveredPrinterInformation: DiscoveredPrinterInformation) {
    if(!foundPrinters.contains(where: {discoveredPrinterInformation.getName() == $0.getName()})) {
  • To start discovering Bluetooth Low Energy devices, call:

    • printerDiscovery.startBlePrinterDiscovery()
  • To stop the discovery scan for Bluetooth Low Energy devices, call:

    • printerDiscovery.stopBlePrinterDiscovery()
  • To find the most recent printer you successfully connected to, call:

    • let lastConnectedPrinter = getLastConnectedPrinterName()