我的应用程序使用谷歌+登录,并在我的appdelegate.swift我有:
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)
}
现在我想插入也Facebook登录,但我必须添加在appdelegate.swift这段代码:
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)
}
但这个返回错误,因为函数'应用程序'已经存在,我怎么才能执行谷歌+和Facebook相同的appdelegate。斯威夫特谢谢。
3条答案
按热度按时间4ktjp1zp1#
你的应用程序应该处理facebook的
and
google链接,然后返回true
,如果一个or
另一个可以处理给定的链接。在
didFinishLaunching
中:ilmyapht2#
在Swift 3中,需要这样做:
覆写并实作下一个方法:
然后道:
rnmwe5a23#
在Swift 5中,你可以这样做: