cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements
Want to learn some quick and useful tips to make your day easier? Check out how Calvin uses Replay to get feedback from other teams at Dropbox here.

Dropbox API Support & Feedback

Find help with the Dropbox API from other developers.

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

DBChooser in Swift3 app - DirectLink = "nil" problem

DBChooser in Swift3 app - DirectLink = "nil" problem

mohergryzie
Explorer | Level 3

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 5

Greg-DB
Dropbox Staff

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
Explorer | Level 3

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
Dropbox Staff
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
Explorer | Level 3

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
Dropbox Staff
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!
Need more support?
Who's talking

Top contributors to this post

  • User avatar
    Greg-DB Dropbox Staff
  • User avatar
    mohergryzie Explorer | Level 3
What do Dropbox user levels mean?