Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.
How do I know when there has been a change in the user's Dropbox account made from outside of the current iOS device such as a new file created? I also need to know if the user logged out, or if a different user logged in on the iOS device. Is there a way that Dropbox notifies my app of these events? Where do I get documentation about those notifications and how to handle them?
To retrieve changes using SwiftyDropbox on iOS, you should use the listFolder and listFolderContinue methods. You can call back to listFolderContinue, passing in the latest cursor value you recieved, to retrieve any new changes.
Also, you can use the listFolderLongpoll method to get low latency updates about when new changes are available, by passing in the latest cursor value you recieved. When it does indicate changes, you can then call back to listFolderContinue to retrieve them.
That's all for file/folder changes only though. Can you elaborate on what information you're looking for when you say you "need to know if the user logged out"? There are a variety of places where the user interacts with Dropbox. Are you referring to them logging out of the official Dropbox web site, the official Dropbox mobile app, the official Dropbox desktop app, or of your own third party app?
I'm using SwiftyDropbox in iOS in my own app. I am wondering what happens if I send a command to Dropbox when the user had logged out. If I set a variable to hold the currently logged in DropboxClient, would the variable become nil if the user had logged out of Dropbox? Is it possible for me to perform an action in Dropbox, thinking that the user is still logged in to Dropbox when in fact he had logged out?
How would I use listFolder, listFolderLongpoll, and listFolderContinue? I pass the cursor from the result into a call of listFolderContinue. Then how would I tell what has changed from the previous query?
Inside of your own app, you control whether or not the user is "logged in". If/when the user indicates that they want to log out, you can have the app throw away any copy of the access token/client it has, and call DropboxClientsManager.unlinkClients to remove it from DropboxClientsManager. You can also optionally call tokenRevoke first to revoke the access token on the Dropbox API servers as well.
And yes, you would set a response handler for the list folder methods, just like other RPC methods in the SDK, as seen in the documentation.
How do I tell from the result I get in the closure I pass to the response method what the changes are? In the closure for the response method I set for listFolder, .entries is thel list of all the current files and folders. What would entries be for the response of the listFolderContinue methods? Would .entries also be the list of current files and folders, or do I get specific information like what had been added and what had been deleted since my last query?
Accessing the ListFolderResult.entries as returned by listFolder is the right way to begin listing the contents of a folder. Note that it is not guaranteed to return all of the results though. The interface is paginated, so you may need to call back to listFolderContinue to get more entries. (It also returns a ListFolderResult.)
Likewise, you can later call back to listFolderContinue again to get any further changes. It will return only things that have changed since your previous call, based on the passed cursor. Please refer to the listFolder documentation for information on how to use these.
Hi there!
If you need more help you can view your support options (expected response time for a 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!