5

I would like to be able to launch the DropBox app within my app. Therefore I would like to know if the DropBox app has a URL scheme that I can use to call openURL, something like this, except I don't know what this string should be.

NSURL *myURL = [NSURL URLWithString:@"dropbox://"];
[[UIApplication sharedApplication] openURL:myURL];
Glorfindel
  • 21,988
  • 13
  • 81
  • 109
mikemeli
  • 725
  • 11
  • 24
  • possible duplicate of [Is there a way to get the URL scheme from the bundle identifier in iOS?](http://stackoverflow.com/questions/9405734/is-there-a-way-to-get-the-url-scheme-from-the-bundle-identifier-in-ios) – coneybeare Feb 23 '12 at 03:28
  • See http://stackoverflow.com/questions/8697488/what-is-the-dropbox-ios-apps-equivalent-of-fb (and Justin's answer). – Abel Apr 03 '12 at 09:55

4 Answers4

4

The only thing you can do with the Dropbox url-scheme is connect your Dropbox App to it. Like this:

var key = "[YOUR API KEY]";
var secret = "[YOUR API SECRET]";
var apiversion = "1";

window.open("dbapi-1://"+apiversion+"/connect?k="+key+"&s="+secret);

Normally the dropbox-app responses by opening your iOS app with the following scheme:

db-[YOU API KEY]://connect?oauth_token=SOMETOKEN&oauth_token_secret=SOMEOATHTOKEN&uid=SOMETHING

or with:

db-[YOU API KEY]://cancel

Got this from looking at the Dropbox SDK for iOS.

Sam
  • 5,375
  • 2
  • 45
  • 54
3

If you need to open a specific file in the iOS Dropbox app, you can use this trick:

  1. Encode your URL.
  2. Append encoded URL to the dbapi-6://1/viewLink?url= prefix.

Attention: this is not documented and may change in future releases.

The whole code should look like this:

// `yourURLString` is the URL string you want to open 

if ([[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:@"dbapi-6://"]) 
{    
    NSString *encodedFileURLString =
        [yourURLString stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];

    NSString *fullURLString = 
        [@"dbapi-6://1/viewLink?url=" stringByAppendingString:encodedFileURLString];

    [[UIApplication sharedApplication] openURL:[NSURL URLWithString:fullURLString]];
}
else
{
    // Otherwise open Safari
    [[UIApplication sharedApplication] openURL:[NSURL URLWithString:yourURLString]];
}
Misha Karpenko
  • 2,168
  • 17
  • 18
3

Dropbox's URL scheme is

dbapi-1://
Daddy
  • 9,045
  • 7
  • 69
  • 98
  • Where did you find that, do you have a reference? When I use Google, I find different schemes and none of them standardized or official. – Abel Mar 31 '12 at 12:05
  • sourced from here: http://stackoverflow.com/questions/8697488/what-is-the-dropbox-ios-apps-equivalent-of-fb – Daddy Apr 03 '12 at 00:16
  • So, it is indeed not a standard URI scheme, but application specific. But, that said, it should work once Dropbox is installed. You can edit your question to contain a link or something, then I can remove the downvote. – Abel Apr 03 '12 at 09:54
2

Dropbox does not have a URL scheme. However, you can interact with Dropbox via UIDocumentInteractionController. You can read about that here. I've seen a few apps that allow you to open files in Dropbox, and I assume this is how that's done.

edc1591
  • 10,146
  • 6
  • 40
  • 63