Forum Discussion

Benne's avatar
Benne
Explorer | Level 3
7 years ago

no response when trying to list files

Hello,

 

I'm trying to take first steps with the dropbox linkage in my iOS App.

 

Here I have following problem:

I'm opening a ViewController (not the first one) and want to list all files which are in the root folder in my Dropbox.

But when I call "

client.files.listFolder(path: "").response { response, error in ..."

it just jumps over the entire code without an errormessage.

 

I have not found any solution yet so I'm hoping someone of you can assist me.

 

Below you see my code.

 

Thank you

 

 

override func viewDidLoad() {
        super.viewDidLoad()
        
        if (DropboxClientsManager.authorizedClient == nil) {
            DropboxClientsManager.authorizeFromController(UIApplication.shared, controller: self, openURL: {(url:URL) -> Void in UIApplication.shared.open(url, options: [:], completionHandler: nil) })
        }
        else {
            print("User is already authorized!")
        }
        
        if let client = DropboxClientsManager.authorizedClient {
            
            client.files.listFolder(path: "").response { response, error in
                if let result = response {
                    for entry in result.entries {
                        self.dataFromServer.append(DataFromServer())
                        self.dataFromServer[self.dataFromServer.count-1].folderName = entry.name
                    }
                } else {
                    print(error!)
                }
            }
        }
        
    }

 

 

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

    Nothing in your code looks wrong, so we'll need to investigate further. Please let me know:

     

    - What version number of the SDK do you have installed?

    - Are you seeing the "User is already authorized" message?

    - Are there files/folders to list in the connected account? (If your app is using the "app folder" permission, note that it will only be able to see the contents of the special app folder itself.)

    - Is your network connection working on the device/simulator?

    - What does your app do after running listFolder? Note that the response callback is asynchronous, so it won't return immediately.

    • Benne's avatar
      Benne
      Explorer | Level 3

      Thanks for your reply.

       

      I think I found my problem.

      For some reason I have to reconnect to my Dropbox if I add a folder.

      If I don't do that I don't get a response.

       

       

      • Greg-DB's avatar
        Greg-DB
        Icon for Dropbox Staff rankDropbox Staff
        You shouldn't have to reconnect your account if you add a folder.

        I tried your code, and it seems to be working for me. If you're still seeing any issues, please let me know the answers to the above questions, and any steps necessary to reproduce the problem.

About Dropbox API Support & Feedback

Node avatar for Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.5,948 PostsLatest Activity: 31 minutes ago
351 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!