I'm trying to add Dropbox authentication to my app, but it's showing me this error:
DropboxSDK: app delegate does not implement application:openURL:sourceApplication:annotation:
Below is the code in my app delegate:
let dbSession = DBSession(appKey: dbAppKey, appSecret: dbAppSecret, root: kDBRootDropbox)
DBSession.setSharedSession(dbSession)
func application(app: UIApplication, openURL url: NSURL, options: [String : AnyObject]) -> Bool {
if DBChooser.defaultChooser().handleOpenURL(url){
return true
}
else if DBSession.sharedSession().handleOpenURL(url){
if DBSession.sharedSession().isLinked(){
return true
}
}
return false
}
I had created an NSObject for authentication and handling other operations related to Dropbox API. Below is my authentication code:
if !DBSession.sharedSession().isLinked(){
DBSession.sharedSession().linkFromController(viewController)
}
else{
delegate.authenticationStatus!(true, error: nil)
}
I'm getting this error after it's successfully logged in. I had also set LSApplicationQueriesSchemes in my plist and also added the URL types. I'm unable to find where I'm making a mistake.
Also I'm trying to check if Dropbox app is present or not using
if UIApplication.sharedApplication().canOpenURL(NSURL(string: "dbapi-1://")!){
}
But it's giving me below error:
canOpenURL: failed for URL: "dbapi-1://" - error: "(null)"
canOpenURL: failed for URL: "dbapi-2://1/connect" - error: "(null)"
Any help will be appreciated.
Thanks in advance.
Your app delegate appears to implement a different openURL
signature than what the SDK expects.
Change the signature to this instead:
func application(application: UIApplication, openURL url: NSURL,
sourceApplication: String?, annotation: AnyObject) -> Bool {
Do take note that this method has been marked deprecated
in the iOS 9 SDK. It will continue to work as expected for a while though.