Background
I am building an Ionic/Cordova application. The primary platform I am targeting is IOS, but the application may ultimately be cross platform. I would like to launch download and open a PDF on the device using an installed PDF viewer. I do not want the user to be prompted to select which application to use when opening the file.
Environment
- Visual Studio 2015 Update 2
- Cordova 6.1.1
- TACO Updated 8.1
- Node 6.0.0
- iPad Mini 2 running iOS 9.2 (13C75)
- iPad Air 2 running 9.2.1 (13D15)
- Adobe Acrobat Reader
Issue Description
When I attempt to open a PDF on an iPad (either the iPad Mini, or Air 2) a small dialog box appears with a list of options in the form of application icons. The options include 'Message', 'Mail', 'Notes' etc. along with 'Copy to Adobe Acrobat'. Choosing the 'Copy to Adobe Acrobat' option will launch my PDF in Adobe Acrobat.
I would like the content to launch with the appropriate application without having to select one from a list. I always want my PDF's to launch in Adobe Acrobat without prompting the user to select an action.
When the same code is executed on Android the PDF is opened using the default PDF viewer as expected.
Relevant Code Sample
Here is the code that is being executed to download the file and to store it on the device along with the call to open the file. In the case of a pdf, mime is set to 'application/pdf'
$cordovaFileTransfer.download(category.assetPath, targetPath, {}, true)
.then(function (result) {
result.file(function (file) {
var localFile = file.localURL;
resolveLocalFileSystemURL(localFile, function (entry) {
var nativePath = entry.toNativeURL();
if (ionic.Platform.isAndroid()) {
nativePath = decodeURIComponent(entry.toURL());
}
// Open in another app, will fail if app doesn't exist that can open the mime type
$cordovaFileOpener2.open(nativePath, mime).then(function () {
// Success!
}, function (err) {
// Error!
});
}, function (error) {
//handle error here
});
}, function (error) {
// handle error here
});
}, function (err) {
// Error
}, function (progress) {
$timeout(function () {
category.downloadProgress = progress.loaded / progress.total;
});
});
}
The Question
Is it possible to open content from my Ionic/Cordova mobile application on an iOS tablet using a default application without the user being prompted every time to select the application?
How do I get the FileOpener2 plugin to open a PDF on an iPad with Adobe Reader installed without asking the user to select the application/action first every time the PDF is selected?