Google Sign In API

前端 未结 3 1395
小鲜肉
小鲜肉 2020-12-21 14:19

First of all need to say that i don\'t use CocoaPods. And it\'s first time when i use Google API.
In Google guide says that i need to configure GIDSignIn in

3条回答
  •  情话喂你
    2020-12-21 15:18

    remove this line from didFinishLaunch GIDSignIn.sharedInstance().delegate = self

    and in your view controller class implement GIDSignInDelegate, GIDSignInUIDelegate protocolos

    and in your view controller viewDidload method write this

    func viewDidLoad() {
        GIDSignIn.sharedInstance().delegate = self
        GIDSignIn.sharedInstance().uiDelegate = self
    }
    

    and don't forget to handle url in app delegate.

    func application(application: UIApplication,
                   openURL url: NSURL, sourceApplication: String?, annotation: AnyObject) -> Bool {
    
    var flag: Bool = false
    
    // handle Facebook url scheme
    if let wasHandled:Bool = FBSDKApplicationDelegate.sharedInstance().application(application, openURL: url, sourceApplication: sourceApplication, annotation: annotation) {
      flag = wasHandled
    }
    
    if let googlePlusFlag: Bool = GIDSignIn.sharedInstance().handleURL(url, sourceApplication: sourceApplication!, annotation: annotation) {
      flag = googlePlusFlag
    }
    
    return flag
    }
    

提交回复
热议问题