title: Fetching basic information (id, first_name) from Facebook by using Social Framework - source code and screenshots attached
body: <p>For what would be a word game later I am trying to fetch very basic information about a player by using Social framework:</p>
  
  <ul>
  <li>id</li>
  <li>first_name</li>
  <li>gender</li>
  <li>location</li>
  </ul>
  
  <p>(i.e. nothing sensitive like <code>email</code> and I don't use Facebook iOS SDK).</p>
  
  <p>So in Xcode 5.0.2 I create a blank single view app for iPhone and add <code>Social.framework</code> to the <em>Build phases</em> tab.</p>
  
  <p>Then I add the following code to the <a href="https://github.com/afarber/ios-newbie/tree/master/MyFacebook/MyFacebook" rel="nofollow noreferrer">ViewController.m</a>:</p>
  
  <pre><code>#import "ViewController.h"
  #import &lt;Social/Social.h&gt;
  #import &lt;Accounts/Accounts.h&gt;
  
  #define FB_APP_ID @"432298283565593"
  //#define FB_APP_ID @"262571703638"
  
  @interface ViewController ()
  @property (strong, nonatomic) ACAccountStore *accountStore;
  @end
  
  @implementation ViewController
  
  - (void)viewDidLoad
  {
      [super viewDidLoad];
  
      NSLog(@"Facebook is available: %d", [SLComposeViewController isAvailableForServiceType:SLServiceTypeFacebook]);
  
      [self getMyDetails];
  }
  
  - (void) getMyDetails {
      if (!_accountStore) {
          _accountStore = [[ACAccountStore alloc] init];
      }
  
      ACAccountType *facebookAccountType = [_accountStore
                                          accountTypeWithAccountTypeIdentifier: ACAccountTypeIdentifierFacebook];
      NSDictionary *options = @{
                                ACFacebookAppIdKey: FB_APP_ID,
                                ACFacebookPermissionsKey: @[@"basic_info"]};
  
      [_accountStore requestAccessToAccountsWithType:facebookAccountType
                                             options:options
                                          completion:^(BOOL granted, NSError *error)
      {
          if (granted) {
              NSLog(@"Basic access granted");
          } else {
              NSLog(@"Basic access denied %@", error);
          }
      }];
  }
  
  @end
  </code></pre>
  
  <p>And create <a href="https://developers.facebook.com/x/apps/432298283565593/" rel="nofollow noreferrer">a new Facebook app</a> for which I specify <code>de.afarber.MyFacebook</code> as the iOS <em>Bundle ID</em>:</p>
  
  <p><img src="https://i.stack.imgur.com/UyMVG.png" alt="enter image description here"></p>
  
  <p>Finally at Apple iTunes Connect I create a new App ID and then a new app (with a dummy icon and even 2 iPhone screenshots attached):</p>
  
  <p><img src="https://i.stack.imgur.com/dYON5.png" alt="enter image description here"></p>
  
  <p><img src="https://i.stack.imgur.com/1cnRO.png" alt="enter image description here"></p>
  
  <p>My Xcode <em>Info</em> tab and the rest of the source code are unchanged:</p>
  
  <p><img src="https://i.stack.imgur.com/82IvZ.png" alt="enter image description here"></p>
  
  <p><strong>UPDATE 2:</strong></p>
  
  <p>I have updated the source code as suggested by helpful comments, thank you.</p>
  
  <p>Also, I have <a href="https://facebook.com/appcenter/video-preferans" rel="nofollow noreferrer">another Facebook game</a>, which works well (since 1-2 years) for an Adobe AIR desktop and mobile apps (but now I try to learn native iOS programming) and I have tried its id <code>262571703638</code> without success.</p>
  
  <p>And I have added <code>FacebookAppID</code> to <code>MyFacebook-Info.plist</code> as suggested by Mohit10 (it seems to me that it is needed for Facebook SDK only, while I try to use Social Framework - but it can't hurt...)</p>
  
  <p>Now I get the debugger output:</p>
  
  <pre><code>2013-12-31 11:08:07.584 MyFacebook[3009:70b] Facebook is available: 1
  2013-12-31 11:08:07.964 MyFacebook[3009:3903] Basic access granted
  </code></pre>
  
  <p>I just need to figure out, how to fetch the id, first_name, gender, location now (and if <code>basic_info</code> is really needed for that)...</p>