Creating a UIPrinter work object from Url for contactless printing

Scenario: an application with locked mode accepts user input (name, etc.) and prints them. User cannot select printer.

My planned solution was to save the URL of the printer that I have, and is in the form:

ipp://<hostname>.local.:5001/<printername>

To create a UIPrinter object from this saved line:

var printerURL = NSUrl.FromString(SettingsService.OptPrinterUrl);
var printer = UIPrinter.FromUrl(printerURL);

Then I call:

printer.ContactPrinter((available) => {
        if (available) {
            //
        }
    });

OR

var printInterface = UIPrintInteractionController.SharedPrintController;
printInterface.PrintToPrinter(printer, (handler, completed, error) =>
                                {
                                    if (!completed && error != null) {
                                        UIAlertView alert = new UIAlertView("Guest Check-In App", "Print Error", null, "Ok", null);
                                        alert.Show();
                                    }
                                });

No positive result.

However, when using the UIPrinter object returned from the UIPrinterPickerController (as shown below), everything works.

var printerPicker = UIPrinterPickerController.FromPrinter(null);
printerPicker.PresentFromRect(new CGRect(0,0,100,100),this.View,true, delegate(UIPrinterPickerController handler, bool completed, NSError error) {
            printer = printerPicker.SelectedPrinter;
        });

I even tried to get the UIPrinter object from PrinterPicker and tried to create a new UIPrinter with UIPrinter.FromUrl using the url from the UIPrinter object taken from PrinterPicker.

UIPrinter, UIPrinterPickerController:

var printerPicker = UIPrinterPickerController.FromPrinter(null);
                        printerPicker.PresentFromRect(new CGRect(0,0,100,100),this.View,true, delegate(UIPrinterPickerController handler, bool completed, NSError error) {
                            printerPickerPrinter = printerPicker.SelectedPrinter;
                        });
var printer = (UIPrinter)UIPrinter.FromObject(printerPickerPrinter);

"" iOS xamarin.

+5
1

iOS. Apple Bug Reporter (47180997), :

Linux contactPrinter. , . - , .

AirPrint. CUPS - .

0

Source: https://habr.com/ru/post/1622839/


All Articles