I take a reference from official document:https://support.brother.com/g/s/es/htmldoc/mobilesdk/guide/discover-printer.html
I use pod to install the Brother Printer SDK
pod 'BRLMPrinterKit'
then I import h file from SDK
nihaod-Bridging-Header:
#import <React/RCTBridgeModule.h>#import <BRLMPrinterKit/BRLMPrinterKit.h>#import <BRLMPrinterKit/BRPtouchNetworkManager.h>#import <BRLMPrinterKit/BRPtouchDeviceInfo.h>#import <BRLMPrinterKit/BRPtouchPrinter.h>#import <BRLMPrinterKit/BRPtouchPrinterData.h>#import <BRLMPrinterKit/BRPtouchPrinterKit.h>#import <BRLMPrinterKit/BRPtouchPrintInfo.h>
LabelPrinter.swift:
import Foundation@objc(LabelPrinter)class LabelPrinter: NSObject, BRPtouchNetworkDelegate { private var networkManager: BRPtouchNetworkManager? @objc func startSearchWiFiPrinter() { print("startSearchWiFiPrinter") let manager = BRPtouchNetworkManager() manager.delegate = self manager.startSearch(5) self.networkManager = manager } // BRPtouchNetworkDelegate func didFinishSearch(_ sender: Any!) { print("start didFinishSearch") guard let manager = sender as? BRPtouchNetworkManager else { return } guard let devices = manager.getPrinterNetInfo() else { return } for deviceInfo in devices { if let deviceInfo = deviceInfo as? BRPtouchDeviceInfo { print("Model: \(String(describing: deviceInfo.strModelName)), IP Address: \(String(describing: deviceInfo.strIPAddress))") } } }}
When I call function startSearchWiFiPrinter
, my log console just print startSearchWiFiPrinter
, and then I thougt it will print start didFinishSearch
after 5 seconds, but nothing happened.
Any one knows why function didFinishSearch
doesn't be triggered ? Thanks.