サインインでは、viewDidLoadでこれを行う必要があります
signIn.clientID = kClientId;
signIn.shouldFetchGoogleUserEmail = YES;
signIn.shouldFetchGoogleUserID = YES;
signIn.scopes = [NSArray arrayWithObjects:
kGTLAuthScopePlusLogin, // defined in GTLPlusConstants.h
nil];
signIn.delegate = self;
次に、2 つのオプションのうちの 1 つを実行する必要がありますが、両方を実行する必要はありません。
オプション 1: クラスを追加するGPPSignInButton
また
オプション 2: これ[signIn authenticate];
をいくつかのボタンに追加する
次に、このように認証を使用します
- (void)finishedWithAuth: (GTMOAuth2Authentication *)auth
error: (NSError *) error
{
if (error) {
// Do some error handling here.
} else {
GTLServicePlus* plusService = [[GTLServicePlus alloc] init];
plusService.retryEnabled = YES;
[plusService setAuthorizer:auth];
GTLQueryPlus *query = [GTLQueryPlus queryForPeopleGetWithUserId:@"me"];
[plusService executeQuery:query
completionHandler:^(GTLServiceTicket *ticket,
GTLPlusPerson *person,
NSError *error) {
if (error) {
GTMLoggerError(@"Error: %@", error);
} else {
// Retrieve the display name and "about me" text
NSString *description = [NSString stringWithFormat:
@"%@\n%@", person.displayName,
person.identifier];
}
}];
}
}
あなたの .h は次のようになります
#import <UIKit/UIKit.h>
#import <GooglePlus/GooglePlus.h>
#import <GoogleOpenSource/GoogleOpenSource.h>
static NSString * const kClientId = @"yourappnumber.apps.googleusercontent.com";
@interface login : UIViewController<GPPSignInDelegate>
@property (retain, nonatomic) IBOutlet GPPSignInButton *signInButton;
@end