I’m trying to use the InAppBrowser plugin to provide an “open attachment” type functionality where a user views a document that may contain links to files (.doc or .pdf) or images (.png). These will be in the form of URL’s i.e they are not local files on the device. I’d like the user to be able to click on any file and have it open up immediately - without requesting that the file be downloaded (and then opened).
This seems to work iOS but I am having no luck on Android - I can only get the InAppBrowser to open a window and at the bottom of the screen you get a “Do You Want To Download this file” prompt.
Is this a limitation in Android that I won’t be able to get around? Does it simply depend on what apps the user has installed on their phone (e.g PDF viewer or whatever)
Would I need to use the File and File-Opener plugins for this instead of the InAppBrowser plugin? (I didn’t want the user to actually download the file unless they requested to do so)
The InAppBrowser is “just” another WebView that loads whatever URLs you throw at it - so from your description I would say that Android just doesn’t know how to display the content and so offers to download it.
What happens in a normal browser, do the documents get displayed as you want?
Using window.open you mean? Actually, when I tried that I just got an empty window. I was looking at InAppBrowser plugin so I could control the UI a bit - back button etc.
I just tried some tests in gmail in Chrome. If I send an e-mail and paste in a link to a png file and also attach a png file using the file attach option, the result is very different for each: when you open that e-mail up - the link prompts you to download the file (the exact same thing I am getting in my Ionic app) - the file attachment appears as a thumbnail preview type thing and when you click on it, the image is opened (in what I guess is the desktop browser’s built in image viewer?) .
I suppose what I would like to do in the Ionic app is to mimic what gmail does when it displays a file attachment? Is that possible?
So to view a PDF file from a URL the InAppBrowser using the system browser causes two annoying prompts for each PDF the user wants to view from this app listing of PDFs. How can we avoid that?
Here is a sample of the screenshots of the two prompts