我正在創建一個使用社交網絡登錄的應用程序。我的問題是Google調用func application(application: UIApplication, openURL url: NSURL, options: [String: AnyObject]) ->Bool
和Facebook,它調用func application(application: UIApplication, openURL url: NSURL, sourceApplication: String?, annotation: AnyObject) -> Bool
。我必須調用這兩個函數,具體取決於我來自哪個社交網絡App Delegate
事情是,在AppDelegate中擁有這兩個函數,Facebook不會讓我回到應用程序,但谷歌。我認爲這兩個功能之間存在衝突。
我試着設置一個標誌變量,但我不能在任何函數之外設置一個if/else語句。
我該怎麼辦?
func application(application: UIApplication, openURL url: NSURL, sourceApplication: String?, annotation: AnyObject) -> Bool {
return FBSDKApplicationDelegate.sharedInstance().application(application, openURL: url, sourceApplication: sourceApplication, annotation: annotation)
}
func application(application: UIApplication,
openURL url: NSURL, options: [String: AnyObject]) -> Bool {
return GIDSignIn.sharedInstance().handleURL(url, sourceApplication: options[UIApplicationOpenURLOptionsSourceApplicationKey] as? String, annotation: options[UIApplicationOpenURLOptionsAnnotationKey])
}
您不能擁有相同委託方法的兩個副本。只用一個。 – rmaddy