Hi:
I have the cordova in-app-browser installed in mi app and it is not working in Android. It works fine in iOS though.
The following screenshot shows the in app browser when it is executed. I am trying to open a PDF file to show it to the user.
The code I am using to open the in app browser is as follows:
this.platform.ready().then(()=>{
cordova.InAppBrowser.open(file.ref, ‘_blank’);
});
Maybe I’m missing something.
I’m using Ionic beta.8 and I’m testing in Android M.
Thanks in advanced.
As said here it seems that in Android (unlike iOS) the in app browser can not process pdf files.
1 Like
Hello, did you settle on a solution for viewing (remote) PDF files for Android?
Please let us know. Thank you.
Hi AlGantori:
The solution I am using is to open the pdf using google viewer inside the inappbrowser.
Hope this helps.
Thanks for the link, here is what is working on my side
openPDFviaGoogleDocs(URL) {
window.open("https://docs.google.com/viewer?url=" + URL, '_blank');
}
I am getting a separate window with “< >” “url” and X on its header. it seems to work on windows browser and Android. It’s modal I close with the X.
I don’t know how to hook a close event from typescript, yet…
I tried installing the latest 1.7.0 inappbrowser but it’s documented syntax did not work
// https://github.com/apache/cordova-plugin-inappbrowser
openPDFcordova(URL) {
var ref = cordova.InAppBrowser.open(URL, '_blank', 'location=yes');
// says undefined ???
}
I did use declare var cordova: any; but I always get an undefined.
the ionic version of inappbrowser works according to its docs with the following:
import { InAppBrowser } from 'ionic-native';
....
openPDFionicnative(URL) {
let browser = new InAppBrowser(URL, '_blank', 'location=yes');
// browser.show() ;
}
$ ionic plugins ls
cordova-plugin-console 1.0.5 "Console"
cordova-plugin-device 1.1.4 "Device"
cordova-plugin-inappbrowser 1.7.1-dev "InAppBrowser"
cordova-plugin-splashscreen 4.0.1 "Splashscreen"
cordova-plugin-statusbar 2.2.1 "StatusBar"
cordova-plugin-whitelist 1.3.1 "Whitelist"
ionic-plugin-keyboard 2.2.1 "Keyboard"
However, I don’t understand what you mean with "google viewer inside the inappbrowser"
Did you ended using the iframe thing suggested in the link?
If you have designed a page/component to host your PDF viewer please share the general concept and code behind.
I am new to JS/TS.
Thank you.