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: 

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

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

manart
New member | Level 2

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 3

Greg-DB
Dropbox Staff

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
New member | Level 2

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
Dropbox Staff

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.) 

Need more support?
Who's talking

Top contributors to this post

  • User avatar
    Greg-DB Dropbox Staff
  • User avatar
    manart New member | Level 2
What do Dropbox user levels mean?