Quantcast
Channel: Active questions tagged react-native+typescript - Stack Overflow
Viewing all articles
Browse latest Browse all 6287

Problem to identify when a WebView Downloads a file

$
0
0

I have been faced a problem in React Native (environment android) to identify when a WebView downloads a file.

The current version of WebView is "react-native-webview": "^11.15.0"

The WebView component charges an url, this url redirects to some web sites and finally downloads a pdf file.

<WebView   onNavigationStateChange={handleWebViewNavigationStateChange}   source={{uri: my_url_link}}   style={styles.webviewStyles}/>

And I have a function that triggers when the url link changes, so my question is how can i handle the download event

const handleWebViewNavigationStateChange = (newNavState: any) => {  // url from the webview state  const {url} = newNavState;  // Handler PDFView  if (url.includes('.pdf')) {    console.log('Its a PDF');  }};

I have been tried with onFileDownload WebView method but only works for IOS platforms. So i want to tried with some native solution, any idea of how can I could handle the download event?


Viewing all articles
Browse latest Browse all 6287

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>