我已经使用传输插件从服务器下载了一个PDF文件,并且我正在尝试使用Inappbrower插件打开文件,我什么都没有得到。我的意思是什么都没有发生。
fileTransfer.download(url, this.file.dataDirectory + file.filename,false,{
headers: {
'authorization': 'bearer xxxx'
}
}).then((entry) => {
console.log('download complete: ' + entry.toURL());
console.log(entry.nativeURL);
const browser = this.iab.create(entry.nativeURL, '_system', 'location=yes'); //here the inappbrowser plugin code.
}, (error) => {
// handle error
console.log(error);
console.log('ERROR');
});
我的console.log(entry.nativeurl(;打印此路径
file:///data/user/0/com.schneider.and/files/Attendance_Policy_Ver_1.0.pdf
尝试将本机url放在浏览器中,看看是否可以跳到确切的.pdf ....
然后尝试
fileTransfer.download(url, this.file.dataDirectory + file.filename,false,{
headers: {
'authorization': 'bearer xxxx'
}
}).then((entry) => {
console.log('download complete: ' + entry.toURL());
console.log(entry.nativeURL);
let browser=new InApp Browser(entry.nativeURL,'_blank');
}, (error) => {
// handle error
console.log(error);
console.log('ERROR');
});
和从'ionic-native'
导入Inappbrowser
import {InAppBrowser} from 'ionic-native';
我使用此代码及其作品
showDocument(){
const options: DocumentViewerOptions = {
title: 'My PDF'
}
const imgeLocation = `${cordova.file.applicationDirectory}www/assets/imgs/${'Jainbhajan-Jeevan-Saar-By-Nirmal-Gangwal-1-ilovepdf-compressed (1).pdf'}`;
this.document.viewDocument(imgeLocation, 'application/pdf', options)
}