使用facebook iOS 6登录

使用facebook iOS 6登录,ios,iphone,ipad,facebook-ios-sdk,Ios,Iphone,Ipad,Facebook Ios Sdk,如何在iOS应用程序中使用facebook实现登录 我听说facebook集成在iOS 6中 使用Facebook登录后,我可以获得用户名吗 是否有任何示例教程显示了这一点 提前感谢。Viewcontroller.h #import <Accounts/ACAccountStore.h> #import <Accounts/ACAccount.h> #import <Social/Social.h> #import <Accounts/ACAccount

如何在iOS应用程序中使用facebook实现登录

我听说facebook集成在iOS 6中

使用Facebook登录后,我可以获得用户名吗

是否有任何示例教程显示了这一点


提前感谢。

Viewcontroller.h

#import <Accounts/ACAccountStore.h>
#import <Accounts/ACAccount.h>
#import <Social/Social.h>
#import <Accounts/ACAccountType.h>
#import <Accounts/ACAccountCredential.h>

@property (strong, nonatomic) ACAccountStore *accountStore;
@property (strong, nonatomic) ACAccount *facebookAccount;

如果您有任何问题,请告诉我。这对您有用吗?显示未声明标识符的使用
dictFB
此处
[self.accountStore requestAccessToAccountsWithType:FBaccountType选项:dictFB completion:^(BOOL已授予,NSError*e){
@Krunal,我编辑了我的代码。查看并回复我。你必须在facebook开发者网站上制作一个应用程序。当我点击按钮时,它会显示我的应用程序想要访问
基本配置文件和朋友列表你想允许访问吗???
我点击了“允许”,但之后什么也没有发生。
-(void)getUserinfo{

  self.accountStore = [[ACAccountStore alloc]init];
    ACAccountType *FBaccountType= [self.accountStore accountTypeWithAccountTypeIdentifier:ACAccountTypeIdentifierFacebook];

    NSArray *accounts = [self.accountStore accountsWithAccountType:FBaccountType];
       self.facebookAccount = [accounts lastObject];

    if (![SLComposeViewController isAvailableForServiceType:SLServiceTypeFacebook]){
        UIAlertView *alt=[[UIAlertView alloc]initWithTitle:@"Error!" message:@"No Facebook Account is set in settings." delegate:nil cancelButtonTitle:@"Ok" otherButtonTitles:nil, nil];
        [alt performSelectorOnMainThread:@selector(show) withObject:nil waitUntilDone:YES];
        [alt release]; 
        return;
    }


  // **********  changed *****
              NSString *key = @"111111111111"; // // Create a Facebook app on developers.facebook.com & get the Key 
    NSDictionary *dictFB = [NSDictionary dictionaryWithObjectsAndKeys:key,ACFacebookAppIdKey,@[@"email"],ACFacebookPermissionsKey, nil];

 // **********  changed *****


   [self.accountStore requestAccessToAccountsWithType:FBaccountType options:dictFB completion:
     ^(BOOL granted, NSError *e) {
         if (granted) {

              NSArray *accounts = [self.accountStore accountsWithAccountType:FBaccountType];
             NSLog(@"%@",accounts);
             //it will always be the last object with single sign on
             self.facebookAccount = [accounts lastObject];
          NSLog(@"%@",accounts); // Check HERE Which Property you need



 NSString *fab_name=[NSString stringWithFormat:@"%@",[[accounts valueForKey:@"properties"]valueForKey:@"ACUIDisplayUsername"]];
     }
 }];


}