0

Google ウェブサイトの指示に従ってGoolge+ サインインを iOS (ObjC を使用) に統合しましたが、デリゲート メソッド (このメソッドに興味がありますfinishedWithAuth:auth:error)GPPSignInが実行されません。デリゲート メソッドで受け取ったアクセス トークンを共有設定に保存する必要があります。

これが私のコードです:

`

-(void)finishedWithAuth:(GTMOAuth2Authentication *)auth
error:(NSError *)error {
    NSLog(@"Received error %@ and auth object %@",error, auth);
    if (error) {
        NSLog(@"error");
    } else {
        NSLog(@"success");
    }
}
- (BOOL)application: (UIApplication *)application
openURL: (NSURL *)url
sourceApplication: (NSString *)sourceApplication
annotation: (id)annotation {
    NSLog(@"application");
    return [GPPURLHandler handleURL:url
                  sourceApplication:sourceApplication
                         annotation:annotation];
}
-(void)refreshInterfaceBasedOnSignIn {
    NSLog(@"refreshInterfaceBasedOnSignIn");
    if ([[GPPSignIn sharedInstance] authentication]) {
        // The user is signed in.
        self.signInButton.hidden = YES;
        [self readProfileInformation];
        // Perform other actions here, such as showing a sign-out button
        [self readProfileInformation];
        NSLog(@"readProfileInformation");
    } else {
        self.signInButton.hidden = NO;
        // Perform other actions here
    }
}
- (void)disconnect {
    [[GPPSignIn sharedInstance] disconnect];
}
- (void)didDisconnectWithError:(NSError *)error {
    if (error) {
        NSLog(@"Received error %@", error);
    } else {
        // The user is signed out and disconnected.
        // Clean up user data as specified by the Google+ terms.
    }
}
- (void)signOut {
    [[GPPSignIn sharedInstance] signOut];
}
-(void)viewDidLoad
{
    [super viewDidLoad];
    // google+ code
    GPPSignIn *signIn = [GPPSignIn sharedInstance];
    signIn.shouldFetchGooglePlusUser = YES;
    // uncommented to fetch  user email
    signIn.shouldFetchGoogleUserEmail = YES;
    // You previously set kClientId in the "Initialize the Google+ client" step
    signIn.clientID = kClientId;
    // Uncomment one of these two statements for the scope you chose in the previous step
    // signIn.scopes = @[ kGTLAuthScopePlusLogin ];
    // uncommented & set to "profile" & "email" scope:
    signIn.scopes = @[ @"profile", @"email" ];
    // Optional: declare signIn.actions, see "app activities"
    signIn.delegate = self;
    // try silent authentication
    [signIn trySilentAuthentication];
}
@end

`

ありがとう

4

1 に答える 1