gellezzz
gellezzz

Reputation: 1263

Dropbox Chooser unable to handle link ios swift

I trying to implement Dropbox Chooser framework in my ios/swift projcet. Everything looks good. But I can't receive link when choose file from Dropbox. Only I see dialog with text "generating link" for a second in Dropbox app. Where is my problem? And sorry for my bad english.

Here is my button in my UIViewController:

func dropboxBtn(sender: AnyObject) {
   // println("dropboxBtn")
    let dbChooser = DBChooser(appKey: "drop-in-app-key")
    dbChooser.openChooserForLinkType(DBChooserLinkTypePreview, fromViewController: self, completion: { (results: [AnyObject]!) -> Void in
        println(results.description)
    })

}

And here is my application function in AppDelegate.swift

func application(application: UIApplication, openURL url: NSURL, sourceApplication: String?, annotation: AnyObject?) -> Bool {

    println("openURL")
    let dbChooser = DBChooser(appKey: "drop-in-app-key")
    if (dbChooser.handleOpenURL(url)) {
        return true
    }

    return false

}

I don't receive anything in the console...

Upvotes: 2

Views: 1045

Answers (1)

gellezzz
gellezzz

Reputation: 1263

I found my problem! I forgot this configuration -> In the URL Schemes enter db-APP_KEY (replacing APP_KEY with the key generated when you created your app). And now my methods is changed. In my UIViewController:

func dropboxBtn(sender: AnyObject) {

    DBChooser.defaultChooser().openChooserForLinkType(DBChooserLinkTypePreview, fromViewController: self, completion: { (results: [AnyObject]!) -> Void in
        println(results.description)
    })
}

In my AppDelegate.swift:

func application(application: UIApplication, openURL url: NSURL, sourceApplication: String?, annotation: AnyObject?) -> Bool {

    if (DBChooser.defaultChooser().handleOpenURL(url)) {
        return true
    }
    return false
}

Upvotes: 1

Related Questions