Dropbox API存在问题

时间:2017-03-05 02:47:00

标签: ios xcode swift3 dropbox-api

我试图在我的应用中使用Dropbox API。我的ViewController.swift中有一个按钮,当用户连接到他的Dropbox帐户时,我想要一个按钮来显示状态" Connect"或"断开"。问题是,当用户按下按钮(表示连接)并填写Dropbox提供给用户的表单时,该按钮不会将状态更改为"断开"。所以这是代码:

的AppDelegate:

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
    // Override point for customization after application launch.

    let appKey = "myappkey"      
    let appSecret = "mysecretappkey"

    let dropboxSession = DBSession(appKey: appKey, appSecret: appSecret, root: kDBRootAppFolder)
    DBSession.setShared(dropboxSession)


    return true
}


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

    if DBSession.shared().handleOpen(url as URL!) {
        if DBSession.shared().isLinked() {
            NotificationCenter.default.post(name: NSNotification.Name(rawValue: "didLinkToDropboxAccountNotification"), object: nil)
            return true
        }
    }

    return false
}

的ViewController:

    override func viewDidLoad() {
    super.viewDidLoad()
    NotificationCenter.default.addObserver(self, selector: #selector(ViewController.handleDidLinkNotification(notification:)), name: NSNotification.Name(rawValue: "didLinkToDropboxAccountNotification"), object: nil)


    if DBSession.shared().isLinked() {
        bbiConnect.title = "Disconnect"
    }

}

func handleDidLinkNotification(notification: NSNotification) {
    bbiConnect.title = "Disconnect"
}


@IBAction func connectToDropbox(_ sender: AnyObject) {

    if !DBSession.shared().isLinked() {
        DBSession.shared().link(from: self)
    }

    else {
        DBSession.shared().unlinkAll()
        bbiConnect.title = "Connect"
    }


}

当我填写表格以登录我的Dropbox帐户时,我收到此错误:

  

DBDemo [78292:2358549] [错误] DropboxSDK:app delegate未实现应用程序:openURL:sourceApplication:annotation:

我正在使用Dropbox SDK的1.3.14版本

1 个答案:

答案 0 :(得分:0)

错误说你没有被称为正确的签名

  

private func application(application:UIApplication,openURL url:URL,sourceApplication:String?,annotation:AnyObject) - >布尔{

更改您的签名并在此处尝试使用Any[string:Any]

  

func application(_ application:UIApplication,open url:URL,                        sourceApplication:String?,annotation:Any) - >布尔