I am using this following block which is mentioned in Facebook Developer. But when my App callbacks from Browser then it
You use this simple block with your expected requirements
if ([FBSDKAccessToken currentAccessToken])
{
[[[FBSDKGraphRequest alloc] initWithGraphPath:@"me" parameters:nil]
startWithCompletionHandler:^(FBSDKGraphRequestConnection *connection, id user, NSError *error)
{
if (!error)
{
// NSDictionary *dictUser = (NSDictionary *)user;
// This dictionary contain user Information which is possible to get from Facebook account.
}
}];
}
For me, the following line caused isCancelled to always be true... idk why
[login logInWithReadPermissions:@[@"public_profile", @"email", @"gender"]
After changing to this... it worked
[login logInWithReadPermissions:@[@"public_profile"]
You must add the following method in your appDelegate
- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation {
return [[FBSDKApplicationDelegate sharedInstance] application:application
openURL:url
sourceApplication:sourceApplication
annotation:annotation];
}
If the above method is not present into AppDelegate then it results into cancelled state.
Refer to : https://developers.facebook.com/docs/ios/getting-started#startcoding
You cant get Email id from Facebook Login....why???
Check this scenario. This might be happening, We cant blame for it to FBSDK.
Hope this will clear some points.
To get user profile try this
if ([FBSDKAccessToken currentAccessToken])
{
[[[FBSDKGraphRequest alloc] initWithGraphPath:@"me" parameters:nil]
startWithCompletionHandler:^(FBSDKGraphRequestConnection *connection, id user, NSError *error)
{
if (!error) {
NSDictionary *dictUser = (NSDictionary *)user;
self.txfName.text = [dictUser objectForKeyNotNull:@"name"];
self.txfEmail.text = [dictUser objectForKeyNotNull:@"email"];
self.txfUserName.text = [[dictUser objectForKey:@"first_name"] lowercaseString];
NSLog(@"image : https://graph.facebook.com/%@/picture?type=small",[dictUser objectForKeyNotNull:@"id"]);
}
}];
}
Hope this would help you