Google Sign In API

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 application:didFinishLaunchingWithOptions: method, but i’m also use Facebook API which is configured in this method. Also when i try to configure G API in this method i receive errors: Type 'AppDelegate' does not conform to protocol 'GIDSignInDelegate' and Value of type 'GIDSignIn' has no member 'configureWithError'.
How can i configure GIDSignIn not in the AppDelegate?

Bridging Header

#ifndef Bridging_Header_h
#define Bridging_Header_h

#import <FBSDKCoreKit/FBSDKCoreKit.h>
#import <FBSDKLoginKit/FBSDKLoginKit.h>
#import <Bolts/Bolts.h>
#import <GoogleSignIn/GoogleSignIn.h>

#endif

AppDelegate

@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {

    var window: UIWindow?


    func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
//        var configureError: NSError?
//        GGLContext.sharedInstance().configureWithError(&configureError)
//        assert(configureError == nil, "Error configuring Google services: \(configureError)")
//
//        GIDSignIn.sharedInstance().delegate = self
        return FBSDKApplicationDelegate.sharedInstance().application(application, didFinishLaunchingWithOptions: launchOptions)
    }

    func application(application: UIApplication, openURL url: NSURL, sourceApplication: String?, annotation: AnyObject) -> Bool {
        return FBSDKApplicationDelegate.sharedInstance().application(
            application,
            openURL: url,
            sourceApplication: sourceApplication,
            annotation: annotation)
    }

    func applicationDidBecomeActive(application: UIApplication) {
        FBSDKAppEvents.activateApp()
    }
}

ViewController

func signIn(signIn: GIDSignIn!, didSignInForUser user: GIDGoogleUser!, withError error: NSError!) {
        if (error == nil) {
            // Perform any operations on signed in user here.
            let userId = user.userID                  // For client-side use only!
            let idToken = user.authentication.idToken // Safe to send to the server
            let fullName = user.profile.name
            let givenName = user.profile.givenName
            let familyName = user.profile.familyName
            let email = user.profile.email

            print(userId)
            print(idToken)
            print(fullName)
            print(givenName)
            print(familyName)
            print(email)

        } else {
            print("\(error.localizedDescription)")
        }
    }

    @IBAction func gPlusLoginButtonPressed(sender: AnyObject) {
        var googleSignIn: GIDSignIn!
        googleSignIn = GIDSignIn.sharedInstance();
        googleSignIn.delegate = self
        googleSignIn.uiDelegate = self
        googleSignIn.shouldFetchBasicProfile = true;
        googleSignIn.clientID = "24189713900-d5i1fokf9eubmb03thavk7ht371210ji.apps.googleusercontent.com"
        googleSignIn.scopes.append("https://www.googleapis.com/auth/plus.login")
        googleSignIn.scopes.append("https://www.googleapis.com/auth/plus.me")
        googleSignIn.scopes.append("profile")
//        googleSignIn.signInSilently()
        googleSignIn.signIn();
    }

  • Displaying a PDF with UIWebView Not Working
  • Convert AnyObject? to String
  • How to check whether now date is during 9:00-18:00
  • iPhone - Debugging a crash when you can't find it
  • Get user swiping direction in UIPageViewController
  • Any way to use Xcode 3 with iOS SDK 4.3?
  • 2 Solutions Collect From Internet About “Google Sign In API”

    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
    }
    

    GGLContext is a part of Google so importing just GoogleSignIn will give you that error. You need to import Google library.

    Link to Google Library 2.0.3
    https://www.gstatic.com/cpdc/a96d915a636d0afb-Google-2.0.3.tar.gz

    To Use Google Sign In. You need to conform to Both GIDSignInDelegate and GIDSignInUIDelegate and Implement delegate Methods.

    class LoginViewController: UIViewController, GIDSignInDelegate, GIDSignInUIDelegate {
    
        func viewDidLoad() {
            GIDSignIn.sharedInstance().clientID = Resources.googlePlusClientId()
            GIDSignIn.sharedInstance().shouldFetchBasicProfile = true
            GIDSignIn.sharedInstance().scopes = ["profile", "email"]
            GIDSignIn.sharedInstance().delegate = self
            GIDSignIn.sharedInstance().uiDelegate = self
        }
    
        func signIn(signIn: GIDSignIn!, didSignInForUser user: GIDGoogleUser!,
                withError error: NSError!) {
        }
    
    }
    

    And In AppDelegate

    func application(application: UIApplication,
        openURL url: NSURL, sourceApplication: String?, annotation: AnyObject?) -> Bool {
            let isFacebookURL = FBSDKApplicationDelegate.sharedInstance().application(application,
                openURL: url,
                sourceApplication: sourceApplication,
                annotation: annotation)
    
            let isGooglePlusURL = GIDSignIn.sharedInstance().handleURL(url,
                sourceApplication: sourceApplication,
                annotation: annotation)
    
            return isFacebookURL || isGooglePlusURL
    }