简体   繁体   中英

Google sign in through my iOS app

I want to add Google sign in integration to my app.But i want to use Google SDK not using cocoa pods,if any one have used this iOS SDK please give me its steps to login and get user details as i am not getting proper document for this.

I am using Google Sign-In SDK 4.0.1 in that delegate methods are not getting called.

I am using the following structure:

- (void)viewDidLoad {
    [super viewDidLoad];

    [GIDSignIn sharedInstance].clientID = @"842331483294-ofk2cbhhfjoga35u1575t4hbq9ek87ii.apps.googleusercontent.com";
    [GIDSignIn sharedInstance].delegate = self;
    [GIDSignIn sharedInstance].uiDelegate  = self;

    // Do any additional setup after loading the view, typically from a nib.
}

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

}
- (void)signIn:(GIDSignIn *)signIn
didDisconnectWithUser:(GIDGoogleUser *)user
     withError:(NSError *)error {
    // Perform any operations when the user disconnects from app here.
    // ...
}

- (void)signInWillDispatch:(GIDSignIn *)signIn error:(NSError *)error {

}

but any of this delegate method is not getting called.

Any help will be appreciated. Thank you

In xcode 8.0 and ios 10 you need to enable keychain sharing in capabilites .

在此处输入图片说明

You can use my demo code but this is not in 4.0.1

Demo code link

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM