Forum Discussion

manart's avatar
manart
New member | Level 2
9 years ago

SwiftyDropbox Swift 3 - No error response when Internet connection is down

Hello,

 

Before upgrading to Swift 3 (Swift 2.2), I was getting an HTTP error when the wifi of my ipad was off. Now I am not getting anything. I am using the latest version of SwiftyDropbox and apart of that, eveything seems to work fine.

 

I already saw in here: https://github.com/dropbox/SwiftyDropbox

 

This:

 

.response { response, error in
        if let response = response {
            print(response)
        } else if let error = error {
            print(error)
        }
    }

and actually that was the way I was doing it. It is just not giving any response when the wifi is off anymore.

 

When the wifi is on and there is internet connection, everything works.

 

What could be happening?

 

Thanks!

 

 

3 Replies

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

    Thanks for the report! I'm not seeing this issue when testing on a device where the WiFi is off before/while making an API call though. I am getting a -1009 error.

     

    So that we can try to reproduce this and investigate, can you let me know:

    - what version of iOS you're seeing this on

    - how you're constructing the client object

     

    Thanks in advance! 

  • manart's avatar
    manart
    New member | Level 2
    9 years ago

    Thanks for getting back to me.

     

    I am using IOS 10.2 - Swift 3 - Xcode 8.2.1. This is what I have:

     

    func test(){

            

            if let client = DropboxClientsManager.authorizedClient {

            

                let destination: (URL, HTTPURLResponse) -> URL = { temporaryURL, response in

                

                    let filePath = file.docsDir.appendingPathComponent("/file.xml")

                

                    return filePath

                }

            

                client.files.download(path: "/file.xml", overwrite: true, destination: destination)

     

                    .response { response, error in

                        if let response = response {

                            print(response)

                        } else if let error = error {

                            print(error)

                        }

                    }

     

                    .progress { progressData in

                        print(progressData)

                }

            }

        }

     

    When the wifi is on and internet is ok, everything works. However, if I turn the wifi off and run it again, I don't get any errors or anything. I think neither the destination and download functions are being called in this situation.

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

    Oh, I see, thanks! For upload and download calls in particular, you won't get the failure when you're offline, since those are automatically handled on a background session. (And in fact, they should automatically continue when you get back online.) 

About Dropbox API Support & Feedback

Node avatar for Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.

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!