Open createObjectURL Blob on Cordova InAppBrowser

谁说胖子不能爱 提交于 2019-12-12 20:24:53

问题


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?


回答1:


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



来源:https://stackoverflow.com/questions/45224447/open-createobjecturl-blob-on-cordova-inappbrowser

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!