I am integrating FB in my app for login & signup purpose in my iOS app..
While i signup with fb from app, i want to know the user has already registered with fb
for that app or not,
if he is already registered then i want to perform login actions
otherwise 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);
}
Is there any way to achieve it?
I did integrate the FBSDK in one of my apps recently, and this is what i did to check if the user is already authorised.
if ([FBSDKAccessToken currentAccessToken]) {
//perform login for your app
}
else {
// perform signup action for your app
}
Hope this helps.
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments