Open a file in iOS - Airdrop app appears


#1

Hello,

i’m using the cordova-plugin-file-opener2 plugin to open a file that i download from my server.
In Android its work fine, but in iOS the Airdrop app appears and the file dont open.
The file can be a .pdf, .xls, .doc or a image.

Here is a snippet:

    var url = 'http://myserver.com/file.pdf';
    var nome = url.split("/").pop();
    var options = {};

    var targetPath = cordova.file.externalDataDirectory + nome;

    if (ionic.Platform.isIOS() || ionic.Platform.isIPad()) {
        targetPath = cordova.file.documentsDirectory + nome;
    }
    
    $cordovaFileTransfer.download(encodeURI(url), targetPath, options, true)
        .then(function (result) {                
            $cordovaFileOpener2.open(
                result.toURL(),
                mimetype
            ).then(function () {
                //sucesso
            }, function (err) {
                var alert = $ionicPopup.alert({
                        title: 'Erro',
                        template: "Erro ao tentar abrir o arquivo!" + JSON.stringify(err)
                    });
            });
        }, function (err) {
            var alert = $ionicPopup.alert({
                title: 'Erro',
                template: "Erro ao tentar fazer o download o arquivo!" + JSON.stringify(err)
            });
        }, function (progress) {
            //$scope.downloadProgress = (progress.loaded / progress.total) * 100;
        });

Any idea??
Anybody knows another method to open a file???

Thanks!!