I have followed the custom UI FBLogin
button for my app.In LoginHomeViewController
I have the FBLogin
button.
Here is code which I am using in ViewDidLoad
FBSDKLoginButton *loginButton = [[FBSDKLoginButton alloc] init];
loginButton.readPermissions = @[@"public_profile", @"email", @"user_friends"];
if ([FBSDKAccessToken currentAccessToken])
{
[[[FBSDKGraphRequest alloc] initWithGraphPath:@"me" parameters:nil] startWithCompletionHandler: ^(FBSDKGraphRequestConnection *connection, id result, NSError *error) {
if (!error)
{
NSLog(@"fetched user:%@", result);
}
}];
}
1) The issue is When first time there is no console output on safari or FB I am logging in I want user details in this view controller i.e. LoginHomeViewController
.
2) Currently Once login done in safari or FB, when I goes back to previous view and enter into this controller i.e. LoginHomeViewController
then am getting user details in
NSLog(@"fetched user:%@", result);
I tried above code in Custom log in button click i.e.
- (IBAction)facebookClcik:(id)sender {
}
But am facing same issue.
Following are my AppDelegate methods
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions : (NSDictionary *)launchOptions
{
[FBSDKLoginButton class];
return [[FBSDKApplicationDelegate sharedInstance] application : application didFinishLaunchingWithOptions : launchOptions];
}
- (BOOL)application : (UIApplication *)application openURL : (NSURL *)url sourceApplication : (NSString *)sourceApplication annotation : (id)annotation
{
return [[FBSDKApplicationDelegate sharedInstance] application : application openURL : url sourceApplication : sourceApplication annotation : annotation];
}
- (void)applicationDidBecomeActive : (UIApplication *)application
{
[FBSDKAppEvents activateApp];
}