You might see that the Dropbox Community team have been busy working on some major updates to the Community itself! So, here is some info on what’s changed, what’s staying the same and what you can expect from the Dropbox Community overall.
Forum Discussion
Anthony B.15
8 years agoExplorer | Level 4
Xcode 9 simulator DropboxClientsManager.authorizeFromController failing.
Using SwiftyDropbox 4.3.0 on iOS. I'm trying to link my app to my Dropbox account on the latest iOS simulator and it is failing with the following errors: -canOpenURL: failed for URL: "dbapi-2://1/...
- 8 years ago
We've seen this happen when the controller passed in to authorizeFromController isn't the top-most controller. The solution would be to make sure that you're passing the top-most view controller when authorizing. For example, with the UISplitViewController case, it's not necessarily self. Can you check if that's what's happening in your case?
Anthony B.15
Explorer | Level 4
The SFSafariViewController does appear but it just seems to hang. It doesn't load the login page and doesn't even show any browser controls.
I've done a little more testing and now find that this only occurs in portrait mode of all the iPad simulators. In landscape mode it works ok. About the only difference here is that I am using a UISplitViewController, but my "link" button is always in the same view controller. In either case, I initiate the authorization sequence as follows:
DropboxClientsManager.authorizeFromController(UIApplication.shared,
controller: self,
openURL: { (url: URL) -> Void in UIApplication.shared.openURL(url)
})
This behavior is strange considering that all this worked correctly before Xcode 9.
Thanks for the help. I'll keep experimenting.
Greg-DB
8 years agoDropbox Staff
We've seen this happen when the controller passed in to authorizeFromController isn't the top-most controller. The solution would be to make sure that you're passing the top-most view controller when authorizing. For example, with the UISplitViewController case, it's not necessarily self. Can you check if that's what's happening in your case?
- Anthony B.158 years agoExplorer | Level 4
Hi Greg. Yes it seems you nailed it.
In my case the solution is to pass the secondary (detail) VC when the UISplitViewController.displayMode is PrimaryOverlay (portrait). By passing 'self' I am passing the top-most VC in the primary view controller (a UINavigationController). Evidently this is ok when the displayMode is AllVisible (landscape).
I like UISplitViewController, but it can create some interesting challenges.
Thanks for your help!
- Lou P.67 years agoHelpful | Level 6
Hi, Just in case you have the more odd version of this issue, where the pop up message just hangs, which took me about 2 weeks to uncover; I neglected to add to my AppDelegate.m, the "openURL" code; (below).
Apparently the simulators would call this and hang. On a real iPhone or iPad, a little pop up window would show up, then things would be fine. But on the simulators after OS 10.13.6, would stop me from connecting. The code below caused it to complete and connect.
I can't thank this forum and stackoverflow for all the help over the years. what a great group of people...thanks so much.
- (BOOL)application:(UIApplication *)app openURL:(NSURL *)url
options:(NSDictionary<UIApplicationOpenURLOptionsKey,id> *)options {
DBOAuthResult *authResult = [DBClientsManager handleRedirectURL:url];
if (authResult != nil) {
if ([authResult isSuccess]) {
NSLog(@"Success! User is logged into Dropbox.");
} else if ([authResult isCancel]) {
NSLog(@"Authorization flow was manually canceled by user!");
} else if ([authResult isError]) {
NSLog(@"Error: %@", authResult);
}
}
return NO;
}
About Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.
5,911 PostsLatest Activity: 6 hours agoIf you need more help you can view your support options (expected response time for an email or 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!