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

Jonas B.6's avatar
Jonas B.6
New member | Level 1
9 years ago

-canOpenURL: failed for URL: "dbapi-2://1/connect" - error: "(null)"

I installed everything like they say in this tutorial: 
And this is the output i get from xcode, when i try to sign in using the iPhone 6s simulator. 

2016-02-06 22:05:42.592 DBDemo[16063:892330] -canOpenURL: failed for URL: "dbapi-2://1/connect" - error: "(null)"

2016-02-06 22:06:05.257 DBDemo[16063:892330] -[DBDemo.ViewController handleDidLinkNotification:]: unrecognized selector sent to instance 0x7f90a2e29f10

2016-02-06 22:06:05.258 DBDemo[16063:892330] *** WebKit discarded an uncaught exception in the webView:decidePolicyForNavigationAction:request:frame:decisionListener: delegate: <NSInvalidArgumentException> -[DBDemo.ViewController handleDidLinkNotification:]: unrecognized selector sent to instance 0x7f90a2e29f10

2016-02-06 22:06:05.260 DBDemo[16063:892330] [WARNING] DropboxSDK: error loading DBConnectController - Error Domain=NSURLErrorDomain Code=-1002 "unsupported URL" UserInfo={NSUnderlyingError=0x7f90a2f2ce70 {Error Domain=kCFErrorDomainCFNetwork Code=-1002 "unsupported URL" UserInfo={NSErrorFailingURLStringKey=db-8koa47slz0cgnns://1/connect?oauth_token_secret=<redacted>&state=6B034EB3-102A-42D0-9578-BE165BAA26D1&oauth_token=<redacted>&uid=<redacted>, NSLocalizedDescription=unsupported URL, NSErrorFailingURLKey=db-8koa47slz0cgnns://1/connect?oauth_token_secret=<redacted>&state=6B034EB3-102A-42D0-9578-BE165BAA26D1&oauth_token=<redacted>&uid=<redacted>}}, NSErrorFailingURLStringKey=db-8koa47slz0cgnns://1/connect?oauth_token_secret=<redacted>&state=6B034EB3-102A-42D0-9578-BE165BAA26D1&oauth_token=<redacted>&uid=<redacted>, NSErrorFailingURLKey=db-8koa47slz0cgnns://1/connect?oauth_token_secret=<redacted>&state=6B034EB3-102A-42D0-9578-BE165BAA26D1&oauth_token=<redacted>&uid=<redacted>, NSLocalizedDescription=unsupported URL}

 

Please help me understand what i am supposed to do about this? I have written the key and the secret in like im supposed to (I think) And the info.plist file also has the LSApplicationQueriesSchemes and the dbapi-2, like its supposed to.

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

    Hi Jonas, can you elaborate on what functionality, if any, isn't working as expected? The "-canOpenURL: failed for URL: "dbapi-2://1/connect" - error: "(null)" message is expected and safe to ignore in the simulator, where the official Dropbox app isn't installed, as the SDK will fall back to the built in flow.

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

    Thanks for clarifying. So it sounds like the login/app authorization flow doesn't work when you get the "unsupported URL" error?

    It looks like you're using the iOS Core SDK in a Swift project. Can you share the relevant code snippets from your app as text so we can try to reproduce this and track down the issue? (Or if you have a sample project to share that would be even better.) Thanks in advance! 

  • Jonas B.6's avatar
    Jonas B.6
    New member | Level 1

    Thank you so much for your reply Gregory! I can see now how my message can be understood that way. But what i mean is, that even when i play the app on my iPhone i get the rest of the error message i posted. every thing works great, until i try to login. at which point i get the error message.

  • Jonas B.6's avatar
    Jonas B.6
    New member | Level 1

    AppDelegate.swift

    import UIKit

     

    @UIApplicationMain

    class AppDelegate: UIResponder, UIApplicationDelegate {

     

        var window: UIWindow?

     

        func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {

            let appKey = "8koa47slz0cgnns"      // Set your own app key value here.

            let appSecret = "<redacted>"   // Set your own app secret value here.

            

            let dropboxSession = DBSession(appKey: appKey, appSecret: appSecret, root: kDBRootAppFolder)

            DBSession.setSharedSession(dropboxSession)

     

            // Override point for customization after application launch.

            return true

        }

     

     

        func application(application: UIApplication, openURL url: NSURL, sourceApplication: String?, annotation: AnyObject) -> Bool {

            

            if DBSession.sharedSession().handleOpenURL(url) {

                if DBSession.sharedSession().isLinked() {

                NSNotificationCenter.defaultCenter().postNotificationName("didLinkToDropboxAccountNotification", object: nil)

                    return true

                }

            }

            

            return false

        }

        

        func applicationWillResignActive(application: UIApplication) {

            // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.

            // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.

        }

     

        func applicationDidEnterBackground(application: UIApplication) {

            // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.

            // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.

        }

     

        func applicationWillEnterForeground(application: UIApplication) {

            // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.

        }

     

        func applicationDidBecomeActive(application: UIApplication) {

            // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.

        }

     

        func applicationWillTerminate(application: UIApplication) {

            // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.

        }

    }

  • Jonas B.6's avatar
    Jonas B.6
    New member | Level 1

    //

    //  ViewController.swift

    //

     

    import UIKit

     

    class ViewController: UIViewController, UITableViewDelegate, UITableViewDataSource {

     

        @IBOutlet weak var tblFiles: UITableView!

        

        @IBOutlet weak var bbiConnect: UIBarButtonItem!

        

        @IBOutlet weak var progressBar: UIProgressView!

        

        

        override func viewDidLoad() {

            super.viewDidLoad()

            // Do any additional setup after loading the view, typically from a nib.

            

            tblFiles.delegate = self

            tblFiles.dataSource = self

            

            progressBar.hidden = true

            

            NSNotificationCenter.defaultCenter().addObserver(self, selector: "handleDidLinkNotification:", name: "didLinkToDropboxAccountNotification", object: nil)

        

            func handleDidLinkNotification(notification: NSNotification) {

                bbiConnect.title = "Disconnect"

            }

            if DBSession.sharedSession().isLinked() {

                bbiConnect.title = "Disconnect"

            }

        }

     

        override func didReceiveMemoryWarning() {

            super.didReceiveMemoryWarning()

            // Dispose of any resources that can be recreated.

        }

     

        

        // MARK: IBAction method implementation

        

        @IBAction func connectToDropbox(sender: AnyObject) {

            

            if !DBSession.sharedSession().isLinked() {

                DBSession.sharedSession().linkFromController(self)

            }

            else {

                DBSession.sharedSession().unlinkAll()

                bbiConnect.title = "Connect"

            }

        }

        

        

        @IBAction func performAction(sender: AnyObject) {

            

        }

        

        

        @IBAction func reloadFiles(sender: AnyObject) {

            

        }

     

        

        // MARK: UITableview method implementation

        

        func numberOfSectionsInTableView(tableView: UITableView) -> Int {

            return 1

        }

        

        func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {

            return 0

        }

        

        func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {

            let cell = UITableViewCell()

            

            return cell

        }

        

        func tableView(tableView: UITableView, heightForRowAtIndexPath indexPath: NSIndexPath) -> CGFloat {

            return 0.0

        }

        

    }

     

  • Jonas B.6's avatar
    Jonas B.6
    New member | Level 1

    Do you need anything else, then my project should look pretty much like the one in the tutorial i linked in the beginning :) But i am of course also happy to send you anything else you need from the project. Again thank you so much for helping :)

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

    Thanks Jonas! That's helpful, and I'm able to reproduce the issue now. 

    The issue is that the "-[DBDemo.ViewController handleDidLinkNotification:]: unrecognized selector sent to instance ..." error occurs inside openURL, causing the openURL operation to itself report the "unsupported URL" error. 

    The actual issue is that in your code, DBDemo.ViewController doesn't actually implement handleDidLinkNotification. You have that defined only inside viewDidLoad. If you move that outside viewDidLoad, both issues no longer occur.

  • Jonas B.6's avatar
    Jonas B.6
    New member | Level 1

    THANK YOU SO MUCH!!!!!!!
    I have spend far too much time trying to fix this, and then you fix it in a day!
    THANK YOU THANK YOU THANK YOU !!!
    :D:DD::D:D

About Dropbox API Support & Feedback

Node avatar for Dropbox API Support & Feedback

Find help with the Dropbox API from other developers.

5,880 PostsLatest Activity: 2 hours ago
325 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!