Reputation: 3838
I have an Angular2+/Cordova app, and I'm making an API request to get a PDF. I'd like to open this PDF in Web + Native environments.
For web I'm opening the window, getting the PDF & creating a Blob from it, then doing createObjectURL
and setting the window's location.href
to that URL. It works well (on Chrome/FF).
On native I'd like to do something similar, but ideally just do a window.open (via the InAppBrowser
plugin) with the URL that came from createObjectURL
. Is this possible? The URL I get back is something like: blob:file:///ef76ad0d-7c7f-4817-915f-9097160d1a58
. Trying to open this via InAppBrowser with a _system
target does absolutely nothing. No errors, no windows, no nothing. Wondering if there are special whitelist or SCP things I need to do for this?
Upvotes: 3
Views: 3324
Reputation: 3838
For reference, I don't like this solution, but I ended up treating web and native differently in this case.
WEB: Open Window --> REST call to get Blob --> createObjectURL with Blob --> set window location href to result of previous step
NATIVE: REST call to get Blob --> Save Blob with Cordova File plugin --> Open saved file with Cordova File Opener plugin
Upvotes: 5