-
Notifications
You must be signed in to change notification settings - Fork 29.7k
Description
Use case
In the Flutter webview we have a navigationDelegate so we can do specific actions in the app based on the url that is being loaded.
In the webview we have a button that downloads a text file. On iOS this file is received in the navigationDelegate as data:text/plain;charset=utf-8,{text}, but on Android nothing happens. So there my research started.
On Android the WebViewClient.shouldOverrideUrlLoading is being overriden and on iOS it is WKNavigationDelegate.decidePolicyForNavigationAction.
According to this StackOverflow answer the decidePolicyForNavigationAction is also used to start a download. However, on Android this is done in setDownloadListener, for example:
webview.setDownloadListener(DownloadListener { url, userAgent, contentDisposition, mimetype, contentLength ->
val i = Intent(Intent.ACTION_VIEW)
i.data = Uri.parse(url)
startActivity(i)
})
Proposal
My proposal is to add setDownloadListener to the webview and send this url to the navigation delegate. We might want to send more information, but this way the behaviour of Android and iOS are exactly the same.