我正在我的应用程序中集成 FB,以便在我的 iOS 应用程序中登录和注册。
当我从应用程序注册 fb 时,我想知道用户是否拥有already registered with fb该应用程序,
如果他已经注册了,那么我想表演login actions
否则signup actions..!!
- (void) loginButton:(FBSDKLoginButton *)loginButton
didCompleteWithResult:(FBSDKLoginManagerLoginResult *)result
error:(NSError *)error{
FBSDKGraphRequest *request = [[FBSDKGraphRequest alloc]
initWithGraphPath:[NSString stringWithFormat:@"/%@",result.token.userID]
parameters:@{ @"fields" : @"id, name, email, first_name, hometown, last_name, location" }
HTTPMethod:@"GET"];
[request startWithCompletionHandler:^(FBSDKGraphRequestConnection *connection, id result, NSError *error) {
[self handleRequestCompletionWithResult:result error:error];
}];
}
- (void)handleRequestCompletionWithResult:(id)result error:(NSError *)error
{
NSString *title = nil;
NSString *message = nil;
if (error) {
title = @"Graph Request Fail";
message = [NSString stringWithFormat:@"Graph API request failed with error:\n %@", error];
} else {
title = @"Graph Request Success";
message = [NSString stringWithFormat:@"Graph API request success with result:\n %@", result];
if(already registered user) {
//perform login for my app
} else {
//perform signup action for my app
}
}
NSLog(@"%@",message);
}
有没有办法实现它?