Hello,
I try to develop a very simple application connected with DropBox.I am looking for example in swift (not in objective C), could you please help me ?
Need to connect, and retrieve list of files in a Dropbox folder.
Many thanks,Sébastien
We don't currently have a Swift sample app for the iOS Core SDK, but it should be possible to use it in a Swift app. There's a blog post here about how to use the Sync SDK in a Swift app:
https://blogs.dropbox.com/developers/2014/09/swift-apps-with-dropbox/
I believe the same basic steps should work with the Core SDK.
Once you have the SDK installed, you should be able to use it as expected. If you run into any specific issues, feel free to post the code and errors here.
hello,thanks for your reply, I make some progress because i discovered an example (https://github.com/tkunstek/elevenchat/tree/master/ElevenChat)
Now i am facing an issue when I try to loadmetadataloadedMetadata failed with error: Error Domain=dropbox.com Code=400 "The operation couldn’t be completed. (dropbox.com error 400.)" UserInfo=0x7fe6f1411c10 {path=/, error=App folder (sandbox) access attempt failed because this app is not configured to have an app folder. Should your access type be 'dropbox' instead?}
my code below:
// dropbox rest client private var dbRestClient: DBRestClient? @IBAction func btconnect(sender: AnyObject) { if !DBSession.sharedSession().isLinked() { // should let use know why ayou are asking for dropbox permissions // now ask for permission DBSession.sharedSession().linkFromController(self) } if dbRestClient == nil { dbRestClient = DBRestClient(session: DBSession.sharedSession()) dbRestClient!.delegate = self } } @IBAction func btList(sender: AnyObject) { dbRestClient?.loadMetadata("/") } func restClient(client: DBRestClient!, loadedMetadata metadata: DBMetadata!){ if (metadata.isDirectory) { println("Folder \(metadata.path) contains:") for FILE in metadata.contents { println(" \(FILE.filename)"); } } } func restClient(client: DBRestClient!, loadMetadataFailedWithError error: NSError!){ println("loadedMetadata failed with error: \(error)") }
any idea ?ThanksSébastien
The error message is indicating that you have the wrong root set. You set that when you construct your DBSession using DBSession:initWithAppKey:appSecret:root:. It sounds like you're supplying kDBRootAppFolder when you should be supplying kDBRootDropbox to match your app registration.
root
DBSession
DBSession:initWithAppKey:appSecret:root:
kDBRootAppFolder
kDBRootDropbox
many thanks, is was exactly my issue...
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool { // setup dropbox let dbSession = DBSession(appKey: "blabla", appSecret: "blabla", root: kDBRootDropbox) //previous value kDBRootAppFolder DBSession.setSharedSession(dbSession) return true }