Facebook和Google登录-冲突(Xcode) [英] Facebook And Google Login - conflict (Xcode)

查看:136
本文介绍了Facebook和Google登录-冲突(Xcode)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

不幸的是,我在这里阅读了一些类似的问题,对我没有太大帮助.

I've read some of the similar questions here, unfortunately, didn't really help me much.

我有一个使用Swift的Xcode项目,目前,我已经集成了Twitter& Facebook登入.我也想用Google登录.到目前为止,我已经按照步骤进行操作,但是我遇到了2个问题:

I have an Xcode project using Swift, currently, I've integrated Twitter & Facebook login. I would like to have Google login as well. I've followed the steps so far, but I've reach to 2 issues:

  1. didFinishLaunchingWithOptions(在AppDelegate.swift中).我已经将Facebook作为返回类型,但是在Google的文档中它要求使用return true.怎么做?这是代码:

  1. didFinishLaunchingWithOptions (in AppDelegate.swift). I already have Facebook as a return type, but in Google's documentation it says it requires return true. How to do that? Here's the code:

func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {


// Google Login
var configureError: NSError?
GGLContext.sharedInstance().configureWithError(&configureError)
assert(configureError == nil, "Error configuring Google services: \(configureError)")

//return true -> Expected by Google

return FBSDKApplicationDelegate.sharedInstance().application(application, didFinishLaunchingWithOptions: launchOptions) }

2)openURL func-此人也希望获得与Google相关的回报,但目前会返回Facebook(基于其文档):

2) openURL func - This one also expects Google related return but it currently returns Facebook (based on their documentation):

    func application(application: UIApplication, openURL url: NSURL, sourceApplication: String?, annotation: AnyObject) -> Bool {

    return FBSDKApplicationDelegate.sharedInstance().application(application, openURL: url, sourceApplication: sourceApplication, annotation: annotation)


    // Required By Google?!
    return GIDSignIn.sharedInstance().handleURL(url, sourceApplication: sourceApplication, annotation: annotation)

}

因此,我在处理这些方面需要帮助.先感谢您!

So, I need so help on handling those. Thank you in advance!

推荐答案

对我来说这有效

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
        // Override point for customization after application launch.
        FIRApp.configure()

        FBSDKApplicationDelegate.sharedInstance().application(application, didFinishLaunchingWithOptions: launchOptions)

        GIDSignIn.sharedInstance().clientID = FIRApp.defaultApp()?.options.clientID            
        return true
    }

func application(_ application: UIApplication, open url: URL, sourceApplication: String?, annotation: Any) -> Bool {
        return FBSDKApplicationDelegate.sharedInstance().application(application, open: url, sourceApplication: sourceApplication,annotation: annotation)
            || GIDSignIn.sharedInstance().handle(url, sourceApplication: sourceApplication, annotation: annotation)
    }

希望能帮助某人.进行了超过3个小时的工作.

hope help someone. was working on it for morethan 3 hours.

这篇关于Facebook和Google登录-冲突(Xcode)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆