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
Bob S.15
8 years agoCollaborator | Level 9
DropboxClientsManager authorizeFromController not doing anything
Hello,
I'm having trouble presenting the Dropbox login to the user. I had it working some time ago, but today I tried it and nothing happens. I make this call and nothing happens.
...
- 8 years ago
Hey Greg,
Finally found it. I was skipping the call to DBClientsManager setupWithAppKey! It was in there, but I was mistakenly skipping it when my app had stored the preference that Dropbox was disconnected. It's weird that that produces no error messages. I found the problem by stepping in the debugger into authorizeFromController and noticing that both my sharedApplication and controller arguments were 'nil', even though they were valid values when I passed them. Then I noticed the assert in that function:
NSAssert([DBOAuthManager sharedOAuthManager] != nil, @"Call `Dropbox.setupWithAppKey` or `Dropbox.setupWithTeamAppKey` before calling this method");
As soon as I saw that, I knew what I had done.
I guess that the assert never fired, because [DBOAuthManager sharedOAuthManager] is a valid number even if you have not called setupWithAppKey?
Anyway thanks for helping me with this problem, I really appreciate it. I'll probably run into more but at least this one is down.
Bob
Greg-DB
Dropbox Staff
You don't have to share your code if you don't want to, but for what it's worth, we won't judge your code! :-)
If the view controller setup seems unlikely to be the problem, perhaps it's something to do with the UIApplication? Is there anything unusual about your [UIApplication sharedApplication] in that app?
In any case, if it helps, the SDK is open source so you can see the definition for authorizeFromController here:
But yes, with the broken app we would also expect the official Dropbox app to get launched if it's installed. It checks if the app is installed first using canOpenUrl via the passed along UIApplication, and then opens it using openUrl, if so. It's possible it's failing somewhere there, but I've always seen output when something goes wrong with that.
Also, as another data point, have you tried it on multiple devices?
And you can programmatically check the SDK version using the kV2SDKVersion constant. Or, you can check the installed version manually in the Cartfile.resolved file. The "~>" Carthage operator is how you request a "compatible" version, so "~> 3.0.11" will give you "3.0.14", for example.
I'm not sure offhand what the expected failure mode is when attempting to use it on iOS 8, but I would expect it to crash, at least during the app authorization flow if not at launch.
Bob S.15
8 years agoCollaborator | Level 9
Hey Greg,
Finally found it. I was skipping the call to DBClientsManager setupWithAppKey! It was in there, but I was mistakenly skipping it when my app had stored the preference that Dropbox was disconnected. It's weird that that produces no error messages. I found the problem by stepping in the debugger into authorizeFromController and noticing that both my sharedApplication and controller arguments were 'nil', even though they were valid values when I passed them. Then I noticed the assert in that function:
NSAssert([DBOAuthManager sharedOAuthManager] != nil, @"Call `Dropbox.setupWithAppKey` or `Dropbox.setupWithTeamAppKey` before calling this method");
As soon as I saw that, I knew what I had done.
I guess that the assert never fired, because [DBOAuthManager sharedOAuthManager] is a valid number even if you have not called setupWithAppKey?
Anyway thanks for helping me with this problem, I really appreciate it. I'll probably run into more but at least this one is down.
Bob
- Greg-DB8 years agoDropbox StaffGreat! I'm glad to hear you tracked this down. I'll ask the team to see if we can make this fail more noisily in that case.
- Greg-DB8 years agoDropbox StaffI'm trying to reproduce this, but in my simple test project I am getting that assert exception thrown when omitting setupWithAppKey and then calling authorizeFromController.
To help us reproduce this, do you know how your app got into a state where [DBOAuthManager sharedOAuthManager] wasn't nil? What was the value of [DBOAuthManager sharedOAuthManager] in that case? - Bob S.158 years agoCollaborator | Level 9
Hey Greg,
Well, I could swear I checked the value of sharedOAuthManager and it was nonzero, but now it shows zero when I do not call setupWithAppKey. However, it doesn't make any difference - even when it is zero, I still don't see any error message. I tried it with DBRoulette and got the same results.
What happens for you when that assert fires? Does that text print out in the console?
Bob
- Greg-DB8 years agoDropbox Staff
I do get an exception thrown with the message:
*** Assertion failure in +[DBClientsManager authorizeFromController:controller:openURL:], test_project/Pods/ObjectiveDropboxOfficial/Source/ObjectiveDropboxOfficial/Platform/ObjectiveDropboxOfficial_iOS/DBClientsManager+MobileAuth-iOS.m:20 2017-04-19 11:40:19.423 test_project[44538:72659315] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Call `Dropbox.setupWithAppKey` or `Dropbox.setupWithTeamAppKey` before calling this method' *** First throw call stack: ( 0 CoreFoundation 0x000000010e14ab0b __exceptionPreprocess + 171 1 libobjc.A.dylib 0x000000010d50c141 objc_exception_throw + 48 2 CoreFoundation 0x000000010e14ecf2 +[NSException raise:format:arguments:] + 98 3 Foundation 0x000000010b63a3b6 -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 193 4 test_project 0x000000010b01bb69 +[DBClientsManager(MobileAuth) authorizeFromController:controller:openURL:] + 393 5 test_project 0x000000010b011a3f -[ViewController didPressLink:] + 223 6 UIKit 0x000000010bca9d22 -[UIApplication sendAction:to:from:forEvent:] + 83 7 UIKit 0x000000010be2e25c -[UIControl sendAction:to:forEvent:] + 67 8 UIKit 0x000000010be2e577 -[UIControl _sendActionsForEvents:withEvent:] + 450 9 UIKit 0x000000010be2d4b2 -[UIControl touchesEnded:withEvent:] + 618 10 UIKit 0x000000010bd1749a -[UIWindow _sendTouchesForEvent:] + 2707 11 UIKit 0x000000010bd18bb0 -[UIWindow sendEvent:] + 4114 12 UIKit 0x000000010bcc57b0 -[UIApplication sendEvent:] + 352 13 UIKit 0x000000010c4a8adc __dispatchPreprocessedEventFromEventQueue + 2926 14 UIKit 0x000000010c4a0a3a __handleEventQueue + 1122 15 CoreFoundation 0x000000010e0f0c01 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17 16 CoreFoundation 0x000000010e0d60cf __CFRunLoopDoSources0 + 527 17 CoreFoundation 0x000000010e0d55ff __CFRunLoopRun + 911 18 CoreFoundation 0x000000010e0d5016 CFRunLoopRunSpecific + 406 19 GraphicsServices 0x0000000113a2ba24 GSEventRunModal + 62 20 UIKit 0x000000010bca80d4 UIApplicationMain + 159 21 test_project 0x000000010b01220f main + 111 22 libdyld.dylib 0x000000010effa65d start + 1 23 ??? 0x0000000000000001 0x0 + 1 ) libc++abi.dylib: terminating with uncaught exception of type NSException
- Bob S.158 years agoCollaborator | Level 9
Huh - I don't get anything. I wonder if I have exceptions turned off somehow?
- Bob S.158 years agoCollaborator | Level 9
I tried putting that exception in the main body of DBRoulette, right after the commented out setupWithAppKey line, and it terminated with the same error you got. But it doesn't seem to fire within the SDK library. Probably unrelated, but it also seems weird to me that when I step into that function, my controller and [UIApplication sharedApplication] arguments show up as nil in the debugger.
- Bob S.158 years agoCollaborator | Level 9
Hey Greg, here is my DBRoulette project, in case you want to try it out. I'd be curious to know whether the assert fires for you.
https://www.dropbox.com/s/teyv6nmhhyfmzyu/dropbox-sdk-obj-c-master.zip?dl=0
- Greg-DB8 years agoDropbox Staff
This project does not fire the assert for me. It does print:
yah 0 yah 0
What's different in this project? Did you change a project setting or is it something in the code?
- Bob S.158 years agoCollaborator | Level 9
Hey Greg,
As far as I know, there is nothing different about the project. I just added the print statements to print out the value of sharedOAuthManager. That's the standalone project you linked to earlier in this thread.
Bob
- Greg-DB8 years agoDropbox StaffInteresting. In that case I'll dig into it further now that I can reproduce it. Thanks!
About Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.
5,882 PostsLatest Activity: 21 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!