2

My app uses Dropbox to allow users to make backups of their core data store. Is there a way to determine programmatically if the Dropbox app has been installed, so I can prompt users to set up the backup? I don't want to bug users who don't use Dropbox, but I want to try to get as many users to use backups as possible.

jscs
  • 63,694
  • 13
  • 151
  • 195
Jason
  • 14,517
  • 25
  • 92
  • 153
  • 1
    You need to check if you can access its URL Scheme. See - http://stackoverflow.com/questions/9406546/does-dropbox-app-on-ios-has-a-url-scheme – Sean Feb 26 '13 at 17:51

2 Answers2

7

Dropbox define their own URI scheme, dbapi-1, and as such you can see if the OS can open URLs using that scheme, as so:

if ([[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:@"dbapi-1://"]]) {
    NSLog(@"Dropbox is installed.");
} else {
    NSLog(@"Dropbox is not installed.");
}
WDUK
  • 18,870
  • 3
  • 64
  • 72
0

The currently accepted answer is not appropriate. dbapi-1 may not always work. It really depends on if you're using the SDK or not (which you should).

If you read the code for DBChooser.m (https://github.com/dropbox/dropbox-ios-dropins-sdk/blob/master/DBChooser/DBChooser.m) you will see the following method:

+ (NSURL*)dbc_chooserURLForAppKey:(NSString*)appKey linkType:(DBChooserLinkType)linkType
{
    NSString *baseURL = [NSString stringWithFormat:@"%@://%@/chooser", kDBCProtocol, kDBCAPIVersion];
    NSString *linkTypeString = [[self class] dbc_getLinkTypeString:linkType];

    return [NSURL URLWithString:[NSString stringWithFormat:@"%@?k=%@&linkType=%@", baseURL, appKey, linkTypeString]];
}

The constant kDBCProtocol is what you need. Currently the latest is dbapi-3. You should always use the one that is corresponding with the framework you are using, if you are using the newest Dropbox sdk.

KVISH
  • 12,923
  • 17
  • 86
  • 162