Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.
I'm able to bring up my dropbox account, but when I pick a file, nothing happens, like the completion handler isn't firing. Here is what I have. I initialize with my own key because I'm using the Sync API as well, so I have two keys.
- (BOOL)application:(UIApplication *)app openURL:(NSURL *)url
sourceApplication:(NSString *)source annotation:(id)annotation
{
DBChooser *chooser = [[DBChooser alloc] initWithAppKey:@"[my key]"];
if ([chooser handleOpenURL:url]) {
// This was a Chooser response and handleOpenURL automatically ran the
// completion block
return YES;
}
return NO;
}
and in my viewController.m
-(IBAction)didPressChooser:(id)sender {
DBChooser *newChooser = [[DBChooser alloc] initWithAppKey:@"[my key]"];
[newChooser openChooserForLinkType:DBChooserLinkTypeDirect
fromViewController:self completion:^(NSArray *results)
{
if ([results count]) {
DBChooserResult *_result = results[0];
NSString *extension = [_result.name pathExtension];
if ([extension isEqualToString:@"m4a"] || [extension isEqualToString:@"wav"] || [extension isEqualToString:@"mp4"] ||[extension isEqualToString:@"mp3"]) {
NSURL *dropboxURL;
dropboxURL = _result.link;
DBFileName = _result.name;
NSURLSessionConfiguration *defaultConfigObject = [NSURLSessionConfiguration defaultSessionConfiguration];
session = [NSURLSession sessionWithConfiguration: defaultConfigObject delegate:self delegateQueue: [NSOperationQueue mainQueue]];
NSURLSessionDownloadTask *getFile = [session downloadTaskWithURL:dropboxURL];
[getFile resume];
}
}
}];
}
[Cross-linking for reference: http://stackoverflow.com/questions/28390549/dropbox-chooser-completion-handler-not-firing ]
I believe the issue may be that you're essentially using two different Choosers in the different code snippets, i.e., by doing [[DBChooser alloc] initWithAppKey
... twice. Can you try it with a shared Chooser object, e.g., by doing [[DBChooser alloc] initWithAppKey
... just once and making the object available in both places ? (In the simple case, you would just use [DBChooser defaultChooser]
.)
Nothing yet. I added @property DBChooser *chooser; to my viewController.h, and in my viewController.m I put:
_chooser = [[DBChooser alloc] initWithAppKey:@"ag56efd9sjxt8vv"];
[_chooser openChooserForLinkType:DBChooserLinkTypeDirect
fromViewController:self completion:^(NSArray *results)
{
if ([results count]) {
DBChooserResult *_result = results[0];
NSString *extension = [_result.name pathExtension];
if ([extension isEqualToString:@"m4a"] || [extension isEqualToString:@"wav"] || [extension isEqualToString:@"mp4"] ||[extension isEqualToString:@"mp3"]) {
NSURL *dropboxURL;
dropboxURL = _result.link;
DBFileName = _result.name;
NSURLSessionConfiguration *defaultConfigObject = [NSURLSessionConfiguration defaultSessionConfiguration];
session = [NSURLSession sessionWithConfiguration: defaultConfigObject delegate:self delegateQueue: [NSOperationQueue mainQueue]];
NSURLSessionDownloadTask *getFile = [session downloadTaskWithURL:dropboxURL];
[getFile resume];
}
}
}];
}
Then in my AppDelegate.h I imported the ViewController.h and put in @property ViewController *viewController;
and then in AppDelegate.m I have
if ([self.viewController.chooser handleOpenURL:url]) {
return YES;
}
Same thing happens. It doesn't return to fire the completion handler.
My permission is set for audio in the Dropbox app console. Not sure if that makes a difference
A correction on that last note. The permissions are simply Drop-ins. Thanks
Thanks for trying that and following up. Can you try it with just defaultChooser
then? You actually don't need to have a separate Drop-ins app anymore anyway, since the key for your Sync API app can use Drop-ins too. (This wasn't always the case, which is why the documentation has the note about initWithAppKey
.)
That is, as long as you have your Sync API app key registered in your URL scheme per the Sync API installation instructions, you can use defaultChooser
without having to store and share a Chooser object manually:
if ([[DBChooser defaultChooser] handleOpenURL:url]) {
and
[[DBChooser defaultChooser] openChooserForLinkType:DBChooserLinkTypeDirect
Thanks Greg. Yep, it does look like the single key I'm using for my sync works for the chooser as long as it's defaultChooser. I'll keep at it. Thanks!
Hi there!
If you need more help you can view your support options (expected response time for a ticket is 24 hours), or contact us on X or Facebook.
For more info on available support options for your Dropbox plan, see this article.
If you found the answer to your question in this Community thread, please 'like' the post to say thanks and to let us know it was useful!