Cut the Clutter: Test Ignore Files Feature - sign up to become a beta tester here.

Forum Discussion

mohergryzie's avatar
mohergryzie
Explorer | Level 3
9 years ago

DBChooser in Swift3 app - DirectLink = "nil" problem

Hi,

 

I'm using DBChooser framework for pdf preview and download from dropbox and then to upload to another server. I stuck on this part of code.

 

ViewController

DBChooser.default().open(for: DBChooserLinkTypeDirect, from: self, completion: { reasults in print(reasults as Any) })

 

DBChooser is working because dropbox is opening and then returning to the app. Hovever it is not holding direct link in directory.

 

let downloadURL = DBChooserResult()
            print(downloadURL.link)
#nil

 

AppDelegate

 func application(application: UIApplication, openURL url: NSURL, sourceApplication: String?, annotation: AnyObject?) -> Bool {
        
        if (DBChooser.default().handleOpen(url as URL!)) {
            return true
        }
        return false
    }

Any ideas what is wrong? 

 

5 Replies

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

    You appear to be constructing your own DBChooserResult object instead of using the one(s) in the results array returned by Dropbox. You should instead do something like this:

     

    DBChooser.default().open(for: DBChooserLinkTypeDirect, from: self, completion: { results in
    
        if ((results?.count) != 0) {
            for case let result as DBChooserResult in results! {
                print(result.link)
            }
        } else {
            print("no results")
        }
    
    })
  • mohergryzie's avatar
    mohergryzie
    Explorer | Level 3
    9 years ago

    Greg, Thank you, but it is still not working. There are no errors but still result of print(result.link) is "". 

     

     

    for case let result as DBChooserResult in results! {
                        print(result.link)
                        MyVariables.fullpdfURL = String(describing: result.link)

    I put some code to set my global variable and it is still "nil". 

  • Greg-DB's avatar
    Greg-DB
    Icon for Dropbox Community Moderator rankDropbox Community Moderator
    9 years ago
    Thanks for following up. The code I shared worked properly for me, so we'll have to look into this further. Can you let me know:
    - the version number of the Chooser SDK you have
    - the version number of the official Dropbox iOS app you have installed
  • mohergryzie's avatar
    mohergryzie
    Explorer | Level 3
    9 years ago

    Greg thanks for response! My app is simply not handling value. I have the newest DBChooser SDK - installed via Cocoa Pods. Dropbox version is 44.2.2.

  • Greg-DB's avatar
    Greg-DB
    Icon for Dropbox Community Moderator rankDropbox Community Moderator
    9 years ago
    Thanks! I actually tested on 44.2.4 though, so can you try upgrading and letting me know if that helps?

    Also, I'm not sure I understand what you mean when you say your "app is simply not handling value". Can you elaborate? Thanks in advance!

About Dropbox API Support & Feedback

Node avatar for Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.6,039 PostsLatest Activity: 2 days ago
416 Following

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