Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

inappwebview and download troubleshooting #1530

Closed
2 tasks done
Ladriel opened this issue Feb 7, 2023 · 3 comments
Closed
2 tasks done

inappwebview and download troubleshooting #1530

Ladriel opened this issue Feb 7, 2023 · 3 comments
Labels
bug Something isn't working

Comments

@Ladriel
Copy link

Ladriel commented Feb 7, 2023

  • I have read the Getting Started section
  • I have already searched for the same problem

For context we are trying to replace os-related browser with one unique webview in our app, mostly for displaying web content.
This plugin seemed like a real good candidate, however i'm still experiencing some discrepancies here and there concerning downloads.
I have already investigated multiple threads and would like definite answers to decide if we have to keep or dismay the use of this plugin.

TLDR : download is working fine for direct access links, however we don't have a mean to recognize server-side protected document download urls all the time.

Environment

Flutter version : 3.X.X
Plugin version : 5.X.X / 6.X.X
Android version : SDK 23/Android 6+
iOS version : iOS 13+
macOS version : Monterey 12.5
Xcode version : 14.2

Device information: Multiple devices, Samsungs, iphone SE

Description

Expected behavior:

Download should be recognized and start for both a direct link to files (i.e.: .../file.pdf url) and also for server restricted access links (i.e: .../api/download/id=XXX).

Current behavior:

At the moment, the onDownloadStartRequest feedback is launching only for direct links => http..url.pdf

Whenever files are sent securely from behind the server this onDownload trigger doesn't launch.
How could one make sure the url we are trying to access is to be handled as a download.

We have the shouldOverrideUrl trigger but navigationAction request doesn't give any hint as to if the destination is a file.
We can hard-code the our download-url recognition here but it should work with any secured url from any site so that's out of the question.

Basically if(urlString.contains(download-pattern)) won't work for any site which isn't ours.

As an alternative we don't have enough informations on onLoadStop to do the same sort of things, unless i'm missing something.

Steps to reproduce

  1. I added the useOnDownloadStart and useShouldOverrideUrlLoading true in settings
  2. When onDownloadStart is triggered i delegate the download to my DownloadService, which works fine
  3. For server protected URL onDownloadStart doesn't trigger. As an alternative if i identify our download URL on shouldOverrideUrl and trigger the download service manually here it does download.
    However it should work for any site and as such i don't have a definitive recognition pattern.
  4. i tried updating to the 6.X.X beta version, but even there the navigationAction.shouldPerformDownload on iOS always returns false for server protected download urls.
  5. i seen the flutter_dowloader plugin recommended however it seems to be lagging behind after latest Android 11 permission related problems, and it is currently changing maintainers and might be discontinued.
  6. i did check out https://github.com/pichillilorenzo/flutter_inappwebview_examples/tree/main/file_download too

In short : Is there an implementation-proof way of detecting download urls (especially server secured ones) ? Independent of whether the file is returned in response content, as an attache file, bytes etc ? Maybe we can get some mime-type, headers for this somewhere but i can't seem to find a solution.

Related threads :
https://gist.github.com/pichillilorenzo/ee74e103fdc324f761c5fde7b73bd430
#1309
#1087
#842

@Ladriel Ladriel added the bug Something isn't working label Feb 7, 2023
@github-actions
Copy link

github-actions bot commented Feb 7, 2023

👋 @Ladriel

NOTE: This comment is auto-generated.

Are you sure you have already searched for the same problem?

Some people open new issues but they didn't search for something similar or for the same issue. Please, search for it using the GitHub issue search box or on the official inappwebview.dev website, or, also, using Google, StackOverflow, etc. before posting a new one. You may already find an answer to your problem!

If this is really a new issue, then thank you for raising it. I will investigate it and get back to you as soon as possible. Please, make sure you have given me as much context as possible! Also, if you didn't already, post a code example that can replicate this issue.

In the meantime, you can already search for some possible solutions online! Because this plugin uses native WebView, you can search online for the same issue adding android WebView [MY ERROR HERE] or ios WKWebView [MY ERROR HERE] keywords.

Following these steps can save you, me, and other people a lot of time, thanks!

@Ladriel Ladriel closed this as completed Feb 10, 2023
@ilovesusu
Copy link

How to solve the problem of not being able to download pictures

Copy link

github-actions bot commented Oct 8, 2024

This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug and a minimal reproduction of the issue.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 8, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants