如何使用google +和facebook登录相同的appdelegate.swift [英] How to use both google+ and facebook login in same appdelegate.swift
问题描述
我的应用程序使用google +登录和我的appdelegate.swift我有:
func应用程序(应用程序:UIApplication,didFinishLaunchingWithOptions launchOptions :[NSObject:AnyObject]?) - > Bool {
/ pre>
//在应用程序启动后重写自定义点。
var configureError:NSError?
GGLContext.sharedInstance()。configureWithError(& configureError)
assert(configureError == nil,配置Google服务时出错:\(configureError))
GIDSignIn。 sharedInstance()。delegate = self
返回true
}
func应用程序(应用程序:UIApplication,
openURL url:NSURL,sourceApplication:String?annotation:AnyObject) - > Bool {
return GIDSignIn.sharedInstance()。handleURL(url,
sourceApplication:sourceApplication,
annotation:annotation)
}
现在我想插入Facebook登录,但我必须添加appdelegate.swift这段代码:
$ b $ func应用程序(应用程序:UIApplication,didFinishLaunchingWithOptions launchOptions:[NSObject:AnyObject]?) - > Bool {
//在应用程序启动后重写自定义点。
return FBSDKApplicationDelegate.sharedInstance()。application(application,didFinishLaunchingWithOptions:launchOptions)
}
func应用程序(应用程序:UIApplication,
openURL url:NSURL,
sourceApplication:String?
注释:AnyObject?) - > Bool {
return FBSDKApplicationDelegate.sharedInstance()。application(
application,
openURL:url,
sourceApplication:sourceApplication,
annotation:annotation)
}
但是这个返回错误是因为函数的应用程序已经存在,我如何执行google +和facebook相同的appdelegate.swift
谢谢。
您的应用程序应该处理Facebook 而在 My app use google+ signin and in my appdelegate.swift i have: Now i would like to insert also facebook login, but i have to add in appdelegate.swift this code: But this return error because the functions 'application' already exist, how can I perform both google+ and facebook same appdelegate.swift
Thank you. Your application should handle facebook And in
这篇关于如何使用google +和facebook登录相同的appdelegate.swift的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!和
google链接,然后返回
true
如果一个或
另一个可以处理给定的链接。应用程序:UIApplication,openURL url:NSURL,sourceApplication:String?注释:AnyObject) - > Bool {
let googleDidHandle = GIDSignIn.sharedInstance()。handleURL(url,
sourceApplication:sourceApplication,
annotation:annotation)
let facebookDidHandle = FBSDKApplicationDelegate.sharedInstance()。application(
application,
openURL:url,
sourceApplication:sourceApplication,
annotation:annotation)
return googleDidHandle || facebookDidHandle
}
didFinishLaunching
:
func应用程序(应用程序:UIApplication,didFinishLaunchingWithOptions launchOptions:[NSObject:AnyObject]?) - > Bool {
//在应用程序启动后重写自定义点。
var configureError:NSError?
GGLContext.sharedInstance()。configureWithError(& configureError)
assert(configureError == nil,配置Google服务时出错:\(configureError))
GIDSignIn。 sharedInstance()。delegate = self
返回FBSDKApplicationDelegate.sharedInstance()。应用程序(应用程序,didFinishLaunchingWithOptions:launchOptions)
}
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
// Override point for customization after application launch.
var configureError: NSError?
GGLContext.sharedInstance().configureWithError(&configureError)
assert(configureError == nil, "Error configuring Google services: \(configureError)")
GIDSignIn.sharedInstance().delegate = self
return true
}
func application(application: UIApplication,
openURL url: NSURL, sourceApplication: String?, annotation: AnyObject) -> Bool {
return GIDSignIn.sharedInstance().handleURL(url,
sourceApplication: sourceApplication,
annotation: annotation)
}
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
// Override point for customization after application launch.
return FBSDKApplicationDelegate.sharedInstance().application(application, didFinishLaunchingWithOptions: launchOptions)
}
func application(application: UIApplication,
openURL url: NSURL,
sourceApplication: String?,
annotation: AnyObject?) -> Bool {
return FBSDKApplicationDelegate.sharedInstance().application(
application,
openURL: url,
sourceApplication: sourceApplication,
annotation: annotation)
}
and
google links, then return true
if one or
the other can handle the given link.func application(application: UIApplication, openURL url: NSURL, sourceApplication: String?, annotation: AnyObject) -> Bool {
let googleDidHandle = GIDSignIn.sharedInstance().handleURL(url,
sourceApplication: sourceApplication,
annotation: annotation)
let facebookDidHandle = FBSDKApplicationDelegate.sharedInstance().application(
application,
openURL: url,
sourceApplication: sourceApplication,
annotation: annotation)
return googleDidHandle || facebookDidHandle
}
didFinishLaunching
:func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
// Override point for customization after application launch.
var configureError: NSError?
GGLContext.sharedInstance().configureWithError(&configureError)
assert(configureError == nil, "Error configuring Google services: \(configureError)")
GIDSignIn.sharedInstance().delegate = self
return FBSDKApplicationDelegate.sharedInstance().application(application, didFinishLaunchingWithOptions: launchOptions)
}