[英]how can I integrate facebook login to my ios app when I already have google sign in in appDelegate.swift?
我正在編寫一個應用程序,我想讓用戶使用Google或Facebook帳戶登錄。 我目前已經實現了google解決方案,現在我想加入facebook,但是我正為一件事情而苦苦掙扎。
在fb登錄教程中,作者要求准備AppDelegate.swift
類中的方法:
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
return FBSDKApplicationDelegate.sharedInstance().application(application, didFinishLaunchingWithOptions: launchOptions)
}
我的問題是我已經使用谷歌登錄邏輯實現了didFinishLaunchingWithOptions
函數:
func application(application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
var configureError: NSError?
GGLContext.sharedInstance().configureWithError(&configureError)
assert(configureError == nil, "Error configuring Google services: \(configureError)")
GIDSignIn.sharedInstance().delegate = self
if let currentUser = GIDSignIn.sharedInstance().currentUser {
print("user is signed in as "+GIDSignIn.sharedInstance().clientID)
let sb = UIStoryboard(name: "Main", bundle: nil)
if let tabBarVC = sb.instantiateViewControllerWithIdentifier("TabController") as? TabController {
window!.rootViewController = tabBarVC
}
} else {
print("user is NOT signed in")
let sb = UIStoryboard(name: "Main", bundle: nil)
if let tabBarVC = sb.instantiateViewControllerWithIdentifier("ViewController") as? ViewController {
window!.rootViewController = tabBarVC
}
}
return true
}
所以現在怎么辦? 有什么辦法可以將這兩種方法連接/合並在一起?
謝謝
只需在同一函數中同時添加facebook和google代碼即可。
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
FBSDKApplicationDelegate.sharedInstance().application(application, didFinishLaunchingWithOptions: launchOptions)
// Google sign in code
// ...
return true
}
返回值(真/假)並不重要。 請參閱本主題以獲取解釋。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.