How can a I use the window.print method in a WebView with react-native

Viewed 794

I'm using react-native and its webview to call a webpage where at the end of a flow of four or five pages, they use the window.print method to print the page. But, when I tap the button to print the page nothing happens. Do you know what can I do in this situation to make the button work?. I've only tried this in Android and I use "react-native-webview": "^5.10.0" with "react-native": "^0.59.9".

1 Answers

I am using a work around for now as my react native webview app only consists of the uri of the web app. What I am doing is I am checking if window.ReactNativeWebView exists or not. If yes, then do window.ReactNativeWebView.print() so for my app it takes me to the external browser of that device and there since window.ReactNativeWebView doesn't exists, I do window.print().

I am not sure if this is the right way to do but if someone has a better solution. I am eagerly waiting for it!

Related