Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

iOs wont open file #167

Closed
rfcabal opened this issue Sep 10, 2017 · 7 comments
Closed

iOs wont open file #167

rfcabal opened this issue Sep 10, 2017 · 7 comments
Labels

Comments

@rfcabal
Copy link

rfcabal commented Sep 10, 2017

Hi Guys

I'm using this plugin to open a file which I downloaded, here is my code:

// Crear nueva transferencia
var fileTransfer = new FileTransfer();
// URL de descarga del archivo
var uri = encodeURI($scope.folder + filename);
// Ruta de donde se descargará el archivo
var filePath = cordova.file.documentsDirectory + filename;

// Descarga de archivo
fileTransfer.download(
uri,
filePath,
function(entry) {

    console.log("download complete: " + entry.toURL());

    // Cambio de estado a descargado
    $scope.download = 2;

    // Abrir el archivo en APP
    cordova.plugins.fileOpener2.showOpenWithDialog(

        cordova.file.documentsDirectory + filename, // Dirección de arhivo la misma que descarga
        'application/pdf', // Tipo MIME del archivo para relacionarlo con aplicaciones
        {
            error: function(e) {
                console.log('Error status: ' + e.status + ' - Error message: ' + e.message);
            },
            success: function() {
                console.log('file opened successfully');
            }
        }
    );

},
function(error) {
    // Estado de archivo no descargado.
    $scope.download = 3;
    // Error en consola.
    console.log("download error source " + error.source);
    console.log("download error target " + error.target);
    console.log("download error code" + error.code);
},
false, {
    //headers: {
    //    "Authorization": "Basic dGVzdHVzZXJuYW1lOnRlc3RwYXNzd29yZA=="
    //}
}
);

It's downloading my file but once is looking for the file to open it, it does nothing.

This is the log from ios simulator
2017-09-10_122530

I was looking for the file in a terminal and the file exist
2017-09-10_122700

I saw this #2 and I use the solution but doesn't work for me

@andycaoz4
Copy link

andycaoz4 commented Sep 18, 2017

I am also running into this issue as well with 'showOpenWithDialog' in iOS. Standard open method works fine, but showopenwithdialog shows nothing. Console says file was opened successfully nevertheless. showOpenWithDialog works perfectly on Android.

What I've tried: file-opener2 ver 2.0.19 on actual iPad Mini.
My file path is: /var/mobile/Containers/Data/Application/499541BB-838D-4E9B-8C21-DF23BBE24FB0/Documents/Library/NoCloud/sleeping-fat-cat.jpg

I used entry.toURL(),

Tried both add/remove in config.xml , didn't fix anything in either case.

Tried both
NSURL *fileURL = [NSURL URLWithString:path]; <--- open file success, but no showopendialog
NSURL *fileURL = [NSURL fileURLWithPath:path]; <--- error out file does not exist

@fpoirier1
Copy link

fpoirier1 commented Oct 3, 2017

+1

Anyone found a fix or alternative to this issue ?

@andycaoz4
Copy link

@fpoirier1, I got it to work from the solutions on 145. It seems the dialog window is indeed showing, but the position was off screen for whatever reason.

#145

@fpoirier1
Copy link

Awesome thanks !

@darylldawn
Copy link

@fpoirier1 Did #145 helped you? Or did you use another solution?

Thanks!

@shnist
Copy link
Collaborator

shnist commented Dec 12, 2018

possible duplicate of #145, which may be resolve by this PR #72

@shnist shnist added the bug label Dec 12, 2018
@shnist
Copy link
Collaborator

shnist commented Dec 17, 2018

closing as duplicate

@shnist shnist closed this as completed Dec 17, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants