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

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

问题描述

不幸的是,我在这里阅读了一些类似的问题,并没有真正帮助我.

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

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

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天全站免登陆