swiftairprintuiprintinteractioncntrler

Swift 5 Error The printer appears to be a different "(Printer name)"


I'm using this function to print directly to printer. The first print is ok but when I try to print another document I get this error:

"The printer "EPSON WF-5710" appears to be different than the previously used printer with the same name or the connection may not be trustworthy. If this is expected, tap "Continue".

How can I resolve this issiue? This is the code that I used for print

  //MARK: -SEND DOCUMENT TO PRINTER
    func printDocument(dataToPrint: Data?){
        let printController = UIPrintInteractionController.shared
        
        let printInfo = UIPrintInfo(dictionary:nil)
        printInfo.outputType = .general
        printInfo.jobName = ""
        printInfo.printerID = AppSettings.printerURL
        printController.printInfo = printInfo
        printController.printingItem = dataToPrint ?? Data()
        
        let url = NSURL(string: AppSettings.printerURL)
        let printerObj =  UIPrinter(url: url! as URL)
    
        printController.print(to: printerObj, completionHandler: nil)
        
        printController.present(animated: true, completionHandler: nil)
    }

Solution

  • I found issiue. Printer was set to redirect http to https and ipp was set to allow only proteced. Now works correctly