Phonegap / iPad - UTI - Document Types ... what to do with the incoming URL

I want to import and export CSV. I figured out how to make the iPad recognize my application as opening CSV files.

From there I got lost. I found explanations on how the iPad sends in my file through the application: didFinishLaunchingWithOptions or handleOpenURL ...

I realized that adding a function called handleOpenURL (url) in my js file gives me the url for the file ... so now I have it.

This is great because now I know that someone opened my application this way. Cool ... BUT how can I grab the contents of this url?

+5
source share
1 answer

GET IT! Woot, that's what I did ...

function handleOpenURL(url)
{
    window.resolveLocalFileSystemURI(url, onResolveSuccess, fail)
}

function onResolveSuccess(fileEntry)
{
    fileEntry.file(win, fail);
}

function win(file) {

    var reader = new FileReader();
    reader.onloadend = function(evt) {
        alert("succes");
        alert(evt.target.result);
    }
    reader.readAsText(file);
}

function fail() {        
    alert('fail');
}
+3
source

All Articles