react-native-print: await RNPrint.selectPrinter() Not Working on iOS IPAD (works normal on iPhones)

I invoked the RNPrint.selectPrinter() on multiple iPads (of many versions) but the select printer menu that normally appears when using the same method on an iPhone doesn’t show up! When on an iPad, pressing the assigned button that would invoke the method would only flash the screen a bit.

Below is the code that I have used

  selectPrinter = async () => {
    if(this.state.selectedPrinter == null || this.state.selectedPrinter == undefined){
      const selectedPrinter = await RNPrint.selectPrinter()
      this.setState({ selectedPrinter })
      console.warn(selectedPrinter)
      console.warn(this.state.selectedPrinter)
    }
  }

This is the printer selection screen which pops on iPhones only (The result I am trying to achieve on iPad) simulator screen shot - iphone x - 2018-04-08 at 15 39 27

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Comments: 17 (4 by maintainers)

Most upvoted comments

@waltershub @christopherdro I found the issue, it’s from the way the dialog is anchored on the iPad.

If you change the code to

[printPicker presentFromRect:CGRectMake(0, 0, 0, 0) inView:view animated:YES completionHandler:completionHandler];

instead of

[printPicker presentFromRect:view.frame inView:view animated:YES completionHandler:completionHandler];

It will show the dialog.

Presumably you would ideally pass the properties of the UI element that the dialog should be displayed near - with 0,0,0,0 it will show it in the top left corner. I think it’s good enough for a stopgap but it’d be nice if someone with more knowledge of objective C can suggest a more appropriate solution…

For those looking for a quick fix to this issue, @nicocrm has a working fork over at: npm install nicocrm/react-native-print. Thanks for the fix!