after some googling and research on these forum I’m still stuck on a seemingly simple problem. I need to render a couple buttons inside a view, one of which will link to a file download (zip or pdf), and the other to an external website URL.
The desired behaviour would be for both to open inside the system default browser, leaving the app (but saving its current state for the user to come back afterwards).
I’ve started from scratch from the tabs template and added some hrefs in the friend details page (with file names and URLs added to the friend sample data in services.json). This code works when run on a browser with ionic serve, but running it on ios emulator or android device won’t work: the file download button seems to do nothing at all, while the website button opens the URL inside the app’s webview.
Thanks, I installed the plugin and now I’m able to open external URLs correctly.
However I’m still unable to get a file download working, when I try the same code with a URL pointing to a .zip or .pdf file the inappbrowser window opens but with no content or any reaction at all.
This is what I tried (both in the simulator for ios and a real Nexus4 device for android):
Hm, I know iOS will display a save to ibooks. Not sure how Android does it. But I’m not too sure if it is possible to download a file to a device is possible.
Do you know if the fact that this code is not working on the ios simulator is perchance related to the simulator itself? I still have no subscription to test the code on a real ios device, will get one in the next few weeks.
I feel however that the “download the PDF” thing is not a good way of solving the issue, as we can’t be sure that the user’s device has a way to display pdf files (especially on android, ios has ibooks as you noted). Am I right?
Also, a seemingly related third question: how does this change in regards to map links? i.e. assigning coords to a button in the app and having it open the default map application with that location pinpointed.
Alternatively you can try the Document Handler plugin
This plugin downloads the file and open it with the default app on the device. If there is no app then it throws an error which can be handled in a callback to take the appropriate action.
This plugin has some issues with file names and also this downloads the files as temp files so they won’t be saved permanently and not accessible outside application.
I think the use of inappbrowser plugin requires wrapping urls in a function call. But, i have page content on my app which comes from a website and contains HTML; which may contain A tags. Does this mean i have to parse all the HTML and replace A tags with onclick events which call a window.open()? That would seem like far more effort than should be required. Is there no way that app can just understand what an A tag is?
Sorry if I up this topic, but i kinda have the same issue. I installed the plugin but still can’t make the link work. I tap on it but the browser doesn’t open. my code is almost this:
where {{web}} is the address in the services.js file.
Little add: I have added the url sanitization to make maps work; in my app.js file there is this function: