Skip to content

Instantly share code, notes, and snippets.

@rossmartin
Last active October 13, 2015 06:18
Show Gist options
  • Save rossmartin/4152655 to your computer and use it in GitHub Desktop.
Save rossmartin/4152655 to your computer and use it in GitHub Desktop.
Inlucde this JavaScript file in your iOS Apps index.html and call the linkDropbox() function to start the Dropbox link process.
function linkDropbox(){ // start the Dropbox link process, make a button call this function on click
cordova.exec(linkDropboxCB, linkDropboxFail, "PhoneGapDropBox", "link", [""]);
}
function linkDropboxCB(){ // this callback fires if the link method in PhoneGapDropbox.m is successful
console.log("link method in PhoneGapDropbox.m executed successfully");
}
function linkDropboxFail(err){ // this fail callback fires if the link method in PhoneGapDropbox.m fails
console.log("linkDropboxFail() - error message is below");
console.log(err);
}
function authDropboxFinished(){ // this will be called from AppDelegate.m once Dropbox has linked & authenticated
window.localStorage.setItem("authDropbox", "true"); // setting local storage variable noting this app has linked with Dropbox
console.log("app successfully linked and authenticated with dropbox");
// At this point you can start making Dropbox API calls - will need to call more methods in PhoneGapDropbox.m to upload/download
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment