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

Jordan B.7's avatar
Jordan B.7
New member | Level 1
9 years ago

Redirect after login not completing and app is closing. (SwiftyDropBox)

I've followed the SwiftyDropbox tutorial and after linking the app to my (user) db account the app just quits with out throwing any errors after the redirect back to the app.

This is my console output. 

These "errors" occur after the button press.

I don't get a console print saying 

"Success! User is logged into Dropbox with token: \(token)"

This is my VC.swift

This is the relevant code in my AppDelegate.swfit 

Console output


 

  • ykchau's avatar
    ykchau
    New member | Level 2

    I've got the similar problem (I can't see your image, it's link was broken), but I found that the reason I've got this problem is because I was changing the name of my app, however the old copy of the app is still installed on the device, therefore, while dropbox api redirect, it go to the old app rather than the new app, so I remove the old app and everything work perfectly!

  • Greg-DB's avatar
    Greg-DB
    Icon for Dropbox Staff rankDropbox Staff

    What version of iOS are you running? The only thing that looks potentially wrong is that you're using the older version of the openURL method.

    There's a note in the tutorial here about that:

    https://www.dropbox.com/developers/documentation/swift#tutorial

    You can use this version for 9.0+:

    func application(app: UIApplication, openURL url: NSURL, options: [String : AnyObject]) -> Bool {

    The version you're using is for <9.0:

    func application(app: UIApplication, openURL url: NSURL, sourceApplication: String?, annotation: AnyObject) -> Bool {
  • Jordan B.7's avatar
    Jordan B.7
    New member | Level 1

    Thanks for the response.

    I am on iOS 9,

    I made the code change to the appropriate openURL method and It still fails to redirect. 

    When I get to the DB login screen and hit "Cancel" It also fails to redirect.

    This is my info.plist

     and code for relevant section:

    <key>LSApplicationQueriesSchemes</key>
    <array>
    <string>dbapi-2</string>
    <string>dbapi-8-emm</string>
    </array>
    <key>CFBundleURLTypes</key>
    <array>
    <dict>
    <key>CFBundleTypeRole</key>
    <string>Editor</string>
    <key>CFBundleURLSchemes</key>
    <array>
    <string>db-u3tf1l9k3flsira</string>
    </array>
    </dict>
    </array>

     

  • Greg-DB's avatar
    Greg-DB
    Icon for Dropbox Staff rankDropbox Staff

    Thanks for the additional information. In your original post though, you said "the app just quits with out throwing any errors after the redirect back to the app", however in your last reply you said it "still fails to redirect". Can you clarify what redirect does or doesn't occur, and when the app quits exactly?

    In any case, if you can provide a sample project, that would be most helpful so we can reproduce it and look into it. Thanks in advance! 

  • Jordan B.7's avatar
    Jordan B.7
    New member | Level 1

    It segues back to a white screen and then the app quits

  • Greg-DB's avatar
    Greg-DB
    Icon for Dropbox Staff rankDropbox Staff

    Thanks Jordan! That actually works fine for me though. I get redirected back to the test app and get the "Success! User is logged into Dropbox with token: ..." message on a device running iOS 9 with the official Dropbox app installed.

    Is this happening on multiple devices/simulators for you?

    You may also want to try deleting the Pods and reinstalling with pod install just in case something was broken in your pod installation.

About Dropbox API Support & Feedback

Node avatar for Dropbox API Support & Feedback

Find help with the Dropbox API from other developers.

5,910 PostsLatest Activity: 3 days ago
333 Following

If 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!