Dropbox Chooser无法处理链接ios swift

时间:2015-01-14 15:43:59

标签: ios swift dropbox-api

我试图在我的ios / swift projcet中实现Dropbox Chooser框架。一切都很好看。但是从Dropbox中选择文件时我无法接收链接。只有我在Dropbox应用程序中看到带有文本“生成链接”的对话框。我的问题在哪里?抱歉我的英语不好。

这是我的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)
    })

}

这是我在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

}

我在控制台中没有收到任何东西......

1 个答案:

答案 0 :(得分:1)

我发现了我的问题! 我忘了这个配置 - >在URL Schemes中输入db-APP_KEY(用创建应用程序时生成的密钥替换APP_KEY)。 现在我的方法改变了。 在我的UIViewController中:

func dropboxBtn(sender: AnyObject) {

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

在我的AppDelegate.swift中:

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

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