Phonegap / iPad -- UTI's - Doc types... what to do with incoming URL

492 views Asked by At

I want to import and export CSV's. I have figured out how to get the iPad to recognize my app as one that opens CSV files.

From there though I am lost. I have found explanations on how the iPad sends in my file via application:didFinishLaunchingWithOptions or handleOpenURL ...

I've figured out that adding a function called handleOpenURL(url) in my js file passes me the url for the file... so now I have this.

That is great because I now know that someone has opened my app this way. Cool... BUT how do I grab the contents of that URL?

1

There are 1 answers

0
Todd Vance On BEST ANSWER

GOT IT! Woot, this is 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');
}