Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Having trouble getting google sign in to work to handle URL

I can seem to understand the problem and I am also receiving error " Use of undeclared type "GIDSignInUIDelegate"

I have tried to reinstall pods, I have all pods needed inside pod file including "GoogleSignIn"

I can't seem to find anything online about the Extra argument either.

import UIKit
import Firebase
import GoogleSignIn

@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
    var window: UIWindow?

    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
        FirebaseApp.configure()
        GIDSignIn.sharedInstance().clientID = FirebaseApp.app()?.options.clientID

        window = UIWindow()
        window?.makeKeyAndVisible()
        let navController = UINavigationController(rootViewController: HomeController())
        navController.navigationBar.barStyle = .black
        window?.rootViewController = navController

        return true
    }

    func application(_ application: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey : Any])
        -> Bool {
            return GIDSignIn.sharedInstance().handle(url,
                                                     sourceApplication:options[UIApplication.OpenURLOptionsKey.sourceApplication] as? String,
                                                     annotation: [:])
    }

I receive error:

Extra Argument 'sourceApplication'

in call beside:

func application(_ application: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey : Any])
    -> Bool {
        return GIDSignIn.sharedInstance().handle(url,
                                                 sourceApplication:options[UIApplication.OpenURLOptionsKey.sourceApplication] as? String,
                                                 annotation: [:])
}
like image 327
DAM MANAGEMENT Avatar asked Aug 20 '19 21:08

DAM MANAGEMENT


3 Answers

I can seem to understand the problem and I am also receiving error " Use of undeclared type "GIDSignInUIDelegate"

2019-08-14 -- v5.0.0

Changes to GIDSignIn: uiDelegate has been replaced with presentingViewController.

the GIDSignInUIDelegate was required to assign self to the uiDelegate.

Since the change that to presentingViewController, you can assign self directly and don't need the delegate anymore so they removed it.

GIDSignIn.sharedInstance()?.uiDelegate = self 

is now

GIDSignIn.sharedInstance()?.presentingViewController = self

and as @efremidze indicated in his reply,

GIDSignIn.sharedInstance().handle(url, sourceApplication:options[UIApplication.OpenURLOptionsKey.sourceApplication] as? String, annotation: [:])

is now simply

GIDSignIn.sharedInstance().handle(url)
like image 180
Muvimotv Avatar answered Nov 15 '22 08:11

Muvimotv


You might be using v5.0.0 of GIDSignIn. They made some changes to handle() parameters.

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

https://developers.google.com/identity/sign-in/ios/sign-in?ver=swift https://developers.google.com/identity/sign-in/ios/release

like image 34
efremidze Avatar answered Nov 15 '22 06:11

efremidze


According to the release note of Google Sign-In:

2019-08-14 -- v5.0.0

Changes to GIDSignIn:
uiDelegate has been replaced with presentingViewController.

To fix the errors:

1. replace all

GIDSignIn.sharedInstance().uiDelegate = yourDelegate

with

GIDSignIn.sharedInstance().presentingViewController = yourDelegate

2. Remove all the conformances to GIDSignInUIDelegate.

like image 38
iMoeNya Avatar answered Nov 15 '22 08:11

iMoeNya