Trouble handling Google sign in Swift 3

前端 未结 5 1663
花落未央
花落未央 2021-01-06 02:30

I am new to iOS and am having trouble with app delegate URL handling in Swift 3, and I could really use some pointers.

The below code works perfectly fine in Swift 2

5条回答
  •  忘掉有多难
    2021-01-06 02:33

    For swift 5 Xcode 10.3 (Latest google signin)

    @available(iOS 9.0, *)
        func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey : Any]) -> Bool {
            let googleDidHandle = GIDSignIn.sharedInstance().handle(url)
    
            return googleDidHandle
        }
    
        func application(_ application: UIApplication,open url: URL, sourceApplication: String?, annotation: Any) -> Bool {
            let googleDidHandle = GIDSignIn.sharedInstance().handle(url)
    
            return googleDidHandle
        }
    

    To open signIn screen on Button click

    @IBAction func btnGoogleSigninClick(_ sender: AnyObject) {
            GIDSignIn.sharedInstance()?.presentingViewController = self
            GIDSignIn.sharedInstance()?.restorePreviousSignIn()
    
            GIDSignIn.sharedInstance().signIn()
        }
    

提交回复
热议问题