简体   繁体   English

如何使用FBLoginView检查Facebook登录?

[英]How to check Facebook Login with FBLoginView?

I am using FBLoginView to login to Facebook. 我正在使用FBLoginView登录到Facebook。

How do I check whether the user is logged in on the next launch? 如何检查用户是否在下次启动时登录?

I want the check to happen at the application level and not in a UIViewController like in the Facebook Tutorial on their Developers site. 我希望检查在应用程序级别进行,而不是在开发人员站点上的Facebook教程中的UIViewController中进行。

If there is no way, then how can I add a Facebook Image which looks like a FBLoginView image to my custom button? 如果无法解决,那么如何向自定义按钮添加看起来像FBLoginView图像的Facebook图像? Where can I find that image? 在哪里可以找到该图像?

There are 2 delegate methods of FBLoginView FBLoginView有2个委托方法

-(void)loginViewShowingLoggedOutUser:(FBLoginView *)loginView

-(void)loginViewShowingLoggedInUser:(FBLoginView *)loginView

The first method would inform you whether the user is logged out and the second method would inform you whether the user is logged in and you can perform your action on the basis of that. 第一种方法将通知您用户是否已注销,第二种方法将通知您用户是否已登录,您可以在此基础上执行操作。

For getting the image of the Profile picture u can use users id or objectID from this delegate method which contains all the user information. 为了获取个人资料图片的图像,您可以使用此委托方法中包含所有用户信息的用户ID或objectID。

-(void)loginViewFetchedUserInfo:(FBLoginView *)loginView user:(id<FBGraphUser>)user
{        
    NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:@"https://graph.facebook.com/%@/picture?type=normal",user.id]];
    NSData  *data = [NSData dataWithContentsOfURL:url];
    UIImage *profileImage = [UIImage imageWithData:data];
}

where the profileImage would contain the user profile Image and you can use that image to show on your custom button. 其中profileImage包含用户个人资料图片,您可以使用该图片在您的自定义按钮上显示。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM