如何检查Facebook是否login设备? 目标C

我正在实施Facebook SDK到我的应用程序。 我正在使用FBLoginView来loginFacebook。 我有一个UIButton ,我用它来分享用户的Facebook墙上。 现在我不想使用FBLoginViewlogin,我想检查是否有Facebook应用程序,如果用户已经login。

 - (IBAction)pickFriendsList:(UIButton *)sender { FBFriendPickerViewController *friendPickerController = [[FBFriendPickerViewController alloc] init]; friendPickerController.title = @"Pick Friends"; [friendPickerController loadData]; // Use the modal wrapper method to display the picker. [friendPickerController presentModallyFromViewController:self animated:YES handler: ^(FBViewController *sender, BOOL donePressed) { if (!donePressed) { return; } NSString* fid; NSString* fbUserName; for (id<FBGraphUser> user in friendPickerController.selection) { NSLog(@"\nuser=%@\n", user); fid = user.id; fbUserName = user.name; NSMutableDictionary* params = [NSMutableDictionary dictionaryWithObjectsAndKeys:@"test", @"message", @"http://webecoist.momtastic.com/wp-content/uploads/2009/01/nature-wonders.jpg", @"picture", @"Sample App", @"name",fid,@"tags",fid,@"to",@"106377336067638",@"place", nil]; [FBRequestConnection startWithGraphPath:[NSString stringWithFormat:@"%@/feed",fid] parameters:params HTTPMethod:@"POST" completionHandler:^(FBRequestConnection *connection,id result,NSError *error) { [FBWebDialogs presentFeedDialogModallyWithSession:nil parameters:params handler:^(FBWebDialogResult result, NSURL *resultURL, NSError *error) { if (error) { // Error launching the dialog or publishing a story. NSLog(@"Error publishing story."); } else { if (result == FBWebDialogResultDialogNotCompleted) { // User clicked the "x" icon NSLog(@"User canceled story publishing."); } else { // Handle the publish feed callback //Tell the user that it worked. } } }]; }]; } }]; } 

我假设你正在使用iOS 6 sdk。 在这种情况下,使用下面的代码(可用于设备)

 if([SLComposeViewController isAvailableForServiceType:SLServiceTypeFacebook]) { //user is already logged in using iOS integrated FB a/c } else { //user is not logged in } 

注意:FBSession不能检查这个标准。 所以使用FBSession进行会话检查与上面的代码有不同的含义。

问候,

检查URL计划fb://

[[UIApplication sharedApplication] canOpenURL:@"fb://"]如果安装了Facebook应用程序,则返回YES。 这篇文章列出了Facebook的可用URLscheme: https : //stackoverflow.com/a/5707825/1511668

也许fb://在线是你正在寻找的。