Google通过我的iOS应用登录

时间:2016-11-14 11:35:53

标签: ios objective-c sdk

我想在我的应用中添加Google登录集成。但我想使用Google SDK不使用可可豆荚,如果有人使用过这个iOS SDK,请给我步骤登录并获取用户详细信息,因为我不是为此获得适当的文件。

我正在使用Google Sign-In SDK 4.0.1,因为没有调用委托方法。

我使用以下结构:

- (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 {

}

但是没有调用任何这种委托方法。

任何帮助将不胜感激。 谢谢

2 个答案:

答案 0 :(得分:2)

在xcode 8.0和ios 10中,您需要在功能中启用钥匙串共享。

enter image description here

答案 1 :(得分:0)

您可以使用我的演示代码,但这不在4.0.1

Demo code link