Reputation: 562
I built an app where user can upload any kind of documents. After successful uploading I am sending back corresponding url as a response. By using that response I was showing uploaded document in preview mode. Now my problem is
After I click on that preview, I want to show that document with in App instead of mobile browser by using inAppBrowser cordova plugin. For this I written following code . It's working as I expect in IOS devices not in android. To debug the use-case I just hard-coded some google image url and tried . I could see that image inAppBrowser view even in android. Only problem with documents which user uploaded through my application.
window.open(url, '_blank');
If something is problem w.r.t permissions, it should not work even in IOS but it's working. So I guess There was a problem with Android. How can I achieve this.
It looks like below, When I click on external link. I couldn't able to see content but I can see URL.
Thanks
Upvotes: 0
Views: 1864
Reputation: 53301
The problem is the Android webview, it can't render some files (most of them), just simple files like images and maybe txt.
Your options are to use '_system'
instead of '_blank'
, that will launch an intent to the system so other app can open the file. The other option is to use a file opener plugin instead of inAppBrowser plugin (there are a lot of file opener plugins)
Upvotes: 0
Reputation: 995
Edit
You may need to add the whitelist plugin. This would explain why it works on iOS but not on android.
https://cordova.apache.org/docs/en/latest/reference/cordova-plugin-whitelist/
Installation
cordova plugin add cordova-plugin-whitelist
Then in your config xml check you have this line:
<access origin="*" />
Original
Have you hooked the in app browser to window.open like this?
window.open = cordova.InAppBrowser.open;
This will enable any window.open calls to be routed to the in app browser.
Also you will need to add the location argument to the window.open call:
window.open(url, '_blank', 'location=yes');
Also ensure you are waiting until deviceready has fired before using the window.open method. I have found some devices load the plugins faster than others.
Upvotes: 1