Your workflow is unique 👨‍💻 -  tell us how you use Dropbox here.

Forum Discussion

alvaro a.2's avatar
alvaro a.2
New member | Level 1
10 years ago

After updating to iOS 9, App gets stuck when trying to login into dropbox

Hi,

My App stopped working after updating to iOS 9 because of the new Apple restriction on canopenurl which forces to register the url schemes you plan to you use in your app. 

I followed this tutorial to register the url schemes for my App: https://blogs.dropbox.com/developers/2015/08/important-update-your-core-api-app-for-ios-9/

However, I am still getting the error  dbapi-2://1/connect" - error: "(null)" when I I run the app in the simulator and try to connect to dropbox.I supposed that is because I don't have the dropbox app in the simulator.

When I run my app in the device I don't get the error because I have dropbox  installed. The problem thought is the App will open dropbox to log the user but then after login, it won't come back to my app and if I come back manually, it won't upload files because it tells me the user is unauthorized.

I read in this post on stackoverflow http://stackoverflow.com/questions/31454686/in-ios9-dropbox-app-is-not-being-opened-instead-webview-is-being-opened-for-log that because of the new restriction, dropbox will have to register url schemes for all apps that support its sdk?

Any advice on how to solve this problem?

 

7 Replies

Replies have been turned off for this discussion
  • Greg-DB's avatar
    Greg-DB
    Icon for Dropbox Community Moderator rankDropbox Community Moderator
    10 years ago

    The null error in the simulator is expected, since the Dropbox app isn't installed, but it should fall back to the built-in authorization flow.

    The restriction in iOS 9 only applies to canOpenURL, and not openURL, so the official Dropbox app itself does not need to register the URL schemes of every app that uses the SDK. (There was a bug in a beta version of iOS 9 that affected this though, so make sure you're running a general release version.)

    If you're seeing an issue with the user not getting redirected back to your app after authorizing it in the Dropbox app, please make sure you've followed all of the instructions from the installation and tutorial pages. If you're still seeing this issue, please follow up here with:

    • the steps to reproduce the issue, including the versions of iOS and the Dropbox iOS SDK you're using
    • the relevant code snippet(s), e.g., where you initialize your DBSession and call linkFromController, if you're using the Core SDK, or the equivalent in SwiftyDropbox
    • the relevant pieces of your app's plist, e.g., where you register LSApplicationQueriesSchemes, as well as your own db-APP_KEY scheme
  • Cross-linking with http://stackoverflow.com/questions/33765981/ios9-unable-to-complete-login-process-when-using-dropbox-sdk on Stack Overflow, which may be the same question.

  • alvaro a.2's avatar
    alvaro a.2
    New member | Level 1
    10 years ago

    Steve, yes I posted the question on stackoverflow as well since I thought I was going to have better luck but since you guys replied to the post. I am deleting the question from stackoverflow.

    Gregory, thanks for replying. My iOS version is 9 and I am using Swiftydropox tutorial and not the tutorial you mentioned which appears to for objective C. The dropbox SDK version I am using, I supposed is for Swift 2, I followed this steps  to install it.

    Here are the functions included in my delegate:

      func application(application: UaIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {   
            
                Dropbox.setupWithAppKey("myappkey")
        
                // Override point for customization after application launch.
                return true
            }



        func application(application: UIApplication, openURL url: NSURL, sourceApplication: String?, annotation: AnyObject) -> Bool {      
                if let authResult = Dropbox.handleRedirectURL(url) {
                    switch authResult {
                    case .Success(let token):
                        print("Success! User is logged into Dropbox.")
                    case .Error(let error, let description):
                        print("Error: \(description)")
                    }
                }
                
                return false
            }

    I noticed the function that handles Authorization never gets call.

    And here is the declaration on my info.Plist

    <key>LSApplicationQueriesSchemes</key>
        <array>
            <string>dbapi-2</string>
        </array>

    Let me know if you need any other information, thanks.

     

     

     

     

     

  • Greg-DB's avatar
    Greg-DB
    Icon for Dropbox Community Moderator rankDropbox Community Moderator
    10 years ago

    Thanks! We'd need to see the actual setupWithAppKey call with your key, as well as where you set up your db-APP_KEY scheme in your plist for this though. If you'd rather not share those publicly, you can open an API ticket here:

    https://www.dropbox.com/developers/contact

  • alvaro a.2's avatar
    alvaro a.2
    New member | Level 1
    10 years ago

    Sure, I can provide that information. Here is db-APP_KEY on my info.Plist file

    <array>
            <dict>
                <key>CFBundleTypeRole</key>
                <string>Editor</string>
                <key>CFBundleURLSchemes</key>
                <array>
                    <string>bd31o3eded5n334</string>
                </array>
            </dict>
        </array>

    And here is the function with the actual setupWithAppKey


        func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
            
            Dropbox.setupWithAppKey("bd31o3eded5n334")

            // Override point for customization after application launch.
            return true
        }

    Let me know if you need to see something else.

  • Greg-DB's avatar
    Greg-DB
    Icon for Dropbox Community Moderator rankDropbox Community Moderator
    10 years ago

    Per the tutorial, the URL scheme you register in CFBundleURLSchemes should be "db-APP_KEY", where "APP_KEY" is your app key. You have just "APP_KEY" registered. This is how the Dropbox app redirects the user back to your app, so just add "db-" to the beginning of that and that should fix it.

  • alvaro a.2's avatar
    alvaro a.2
    New member | Level 1
    10 years ago

    Yes! that did it. I just needed to add "db-" to make it work. Good  catch, I guess I couldn't have done it on my own, I never suspected there was something wrong with my APP-KEY.

    Thanks Gregory!

     

About Dropbox API Support and Feedback

Node avatar for Dropbox API Support and Feedback
Get help with the Dropbox API from fellow developers and experts.

The Dropbox Community team is active from Monday to Friday. We try to respond to you as soon as we can, usually within 2 hours.

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, Facebook or Instagram.

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!