cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements
Want to learn some quick and useful tips to make your day easier? Check out how Calvin uses Replay to get feedback from other teams at Dropbox here.

Dropbox API Support & Feedback

Find help with the Dropbox API from other developers.

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

DBChooser and iOS 9 not returning to original app

DBChooser and iOS 9 not returning to original app

Matt m.53
New member | Level 1

Hi,

I had a simple implementation of DBChooser in my iPad app, and it worked fine up until the moment I upgraded my device and SDK to iOS 9.

What happens now is:
1) My app launches DBChooser (DBChooserLinkTypeDirect)
2) Dropbox appears
3) I pick my file
4) I get a 'Generating Link' message
5) I remain in the DropBox app instead of being returned to my app. openURL: is never called

I have set all of the URL schemes, and there are no syslog errors generated and, like I said, it used to work just fine.

I've tried all sorts of solutions, including creating brand new test apps that do nothing but fire up DBChooser. On one occasion, I created a completely new Xcode app, and a brand new DropBox app that used a new key, and the behavior changed slightly. This time, DropBox launched my app after I selected the file (openURL: was called in my app), and then DropBox was immediately launched over the top of my app again. This behavior happened 3 times in a row, and on the 4th (with no changes to the code or app setup), it went back to simply not exiting DropBox at all.

I've uninstalled DB and reinstalled it several times, written test apps, and gone over the docs with a fine tooth comb, but I simply can't get it behaving like it used to in iOS 8, which leads me to suspect the root cause is something to do with the new iOS 9 security stuff that went in. I've read reports from the iOS 9 beta that due to an iOS bug, openURL: had the extra security schemes that canOpenURL: now has, which might cause problems. openURL: should function as it used to in previous SDKs, according to Apple.

Can anybody shed some light on this? Has anybody else seen similar behavior?

Cheers,
Matt. 

10 Replies 10

Steve M.
Dropbox Staff

Moved to the API forum.

Have you read through https://blogs.dropbox.com/developers/2015/08/important-update-your-core-api-app-for-ios-9/ and added dbapi-1 and dbapi-3 to your plist?

Can you share some sample code to reproduce the issue?

Matt m.53
New member | Level 1

Hi Steve,

Thanks for your reply.

Yes, I've added the dbapi schemes to my plist, and here is the code I used for my super simple test (from a completely fresh Xcode new project):

In AppDelegate.m:

-(BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation
{
if ([[DBChooser defaultChooser] handleOpenURL:url])
{
NSLog(@"In openURL.");
return YES;
}

return NO;
}

And then in ViewController.m:

-(void)viewDidAppear:(BOOL)animated
{
[[DBChooser defaultChooser] openChooserForLinkType:DBChooserLinkTypeDirect fromViewController:self completion:^(NSArray *results)
{
if ([results count])
{
NSLog(@"Got file link.");
}
else
{
NSLog(@"Action canceled.");
}
}];
}

As you can see, there isn't much to it. The moment the app launches, it goes straight into DBChooser (which works), but the completion block in ViewController.m is never called, nor is openURL in AppDelegate.m, so control is never returned to my app from DBChooser.

This is on an iPad running 9.0.2. I am installing 9.1 now to see if that changes anything, but if not then I'm at a bit of a loss as to what's going on. I'd be really interested in someone else trying this test code just to see if I'm being bone-headed somewhere. I've created several apps from scratch in Xcode, and have followed the DropBox step-by-step setup over and over in an attempt to make sure I didn't miss anything. Like I said, it used to work on 8.x, and seemingly in 9.x the only change needed is to add the dbapi schemes, which I've done, hence the scratching of my head. 🙂

Any suggestions would be greatly appreciated.

Cheers,
Matt.

PS. I had to retype the code into this post because copy and paste didn't work very well, so if there are any typos in the source, ignore them - the code compiles and runs fine.

Steve M.
Dropbox Staff

From your code here, it looks like you launch the Chooser every time viewDidAppear is invoked. Wouldn't that cause the exact loop you describe? (After choosing a file, the Chooser just gets immediately launched again.)

Matt m.53
New member | Level 1

Sorry, yes you're absolutely right, but for the purpose of this simple test, I had a breakpoint in viewDidAppear as well as in openURL, and also the completion block (probably should have mentioned that! :). I just wanted to ensure that control was returned to me.

DBChooser never returns to my app at all once you select a file (which is what used to happen).

Greg-DB
Dropbox Staff

Can you post the relevant snippets of your app's plist? I.e., the db-APP_KEY URL Type registration, as well as LSApplicationQueriesSchemes? I'm trying to reproduce this behavior.

Also, what version of the Dropbox for iOS app do you have installed?

Matt m.53
New member | Level 1

Hi Gregory,

I'm using the latest DBChooser from the DB website - v1.2.1 (11th Feb, 2014). I'm assuming that's the latest?

From my .plist file:

<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleTypeRole</key>
<string>Editor</string>
<key>CFBundleURLSchemes</key>
<array>
<string>db-MY_APP_KEY</string>
</array>
</dict>
</array>

<key>LSApplicationQueriesSchemes</key>
<array>
<string>dbapi-1</string>
<string>dbapi-3</string>
</array>

Naturally, MY_APP_KEY is replaced with my actual app key.

Cheers,
Matt.

PS. I'm still waiting for the latest Xcode to install so I can test it on 9.1.

Greg-DB
Dropbox Staff

Thanks! And yes that's the latest version of the iOS Chooser SDK. I was actually asking for the version number of the official Dropbox app though if you could copy that over. (In the Dropbox app, in the Settings tab, the "App Version" field.)

Matt m.53
New member | Level 1

Oh! 🙂

v4.1 of the DB app.

Matt m.53
New member | Level 1

UPDATE: Functionality is back to normal on iOS9.1.

I didn't change a thing, other than updating to 9.1, and it works again. There must have been a bug in openURL in the v9.0.x SDK.

Apologies for the waste of time, but thanks for your help anyway. 🙂

Cheers,
Matt.

Need more support?
Who's talking

Top contributors to this post

  • User avatar
    Greg-DB Dropbox Staff
  • User avatar
    Matt m.53 New member | Level 1
What do Dropbox user levels mean?