Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I also experienced some difficulties when working with the Accounts Framework and the Facebook integration. Here is what I've learned and how I got it working.</p> <p><strong>1. Make sure you've setup your App on Facebook correctly</strong><br> You need to set how your App integrates with Facebook to <strong>Native iOS App</strong> and enter the Bundle ID of your App into the designated field. (Edit: Note that bundle IDs are case sensitive) You can set the iTunes ID to 0 for now. Enable <em>Facebook Login</em> and set the <em>App Type</em> in the advanced settings tab to <strong>Native/Desktop</strong>.<br> Also set <em>App Secret in Client</em> to <strong>No</strong>. </p> <p>If one or more of these options are not set correctly it's very likely you get the error <code>The Facebook server could not fulfill this access request: remote_app_id does not match stored id</code>.</p> <p>(Edit: You also have to ensure the sandbox is disabled.)</p> <p><strong>2. Installing the Facebook App for the first time</strong><br> When first installing an App via the native Facebook integration on iOS (and Mac OS X too), you must ask for a basic read permission only! Nothing else as <code>email</code>, <code>user_birthday</code> and <code>user_location</code> is allowed here. Using <code>user_about_me</code>, which is also a basic read permission according to the Facebook documentation, does not work. This is pretty confusing if you previously worked with the Facebook JavaScript SDK or the Facebook PHP SDK, because it asks for the basic permissions by default without you having to do something. Facebook also updated their documentation with a short step-by-step guide on <a href="https://developers.facebook.com/docs/howtos/ios-6/" rel="noreferrer">how to use the new Facebook SDK</a> on iOS 6.</p> <p><strong>3. Requesting additional permissions</strong><br> It's important to know, that you may not ask for read and write permissions at the same time. That's also something experienced Facebook SDK developers may find confusing. Requesting the <code>read_stream</code> permission along with the <code>publish_stream</code> permission will make the request fail, resulting in the error <em>An app may not aks for read and write permissions at the same time</em>. </p> <p>As Facebook does not really distinguish between read/write permissions in the <a href="https://developers.facebook.com/docs/authentication/permissions/#extended_perms" rel="noreferrer">Permission Reference</a>, you must identify write permissions by yourself. They're usually prefixed with <code>manage_*</code>, <code>publish_*</code>, <code>create_*</code> or suffixed by <code>*_management</code>.</p> <p>Facebook does also not recommend to ask for additional permissions immediately after getting basic permissions. The <a href="https://developers.facebook.com/docs/tutorial/iossdk/upgrading-from-3.0-to-3.1/" rel="noreferrer">documentation</a> says "You are now required to request read and publish permission separately (and in that order). Most likely, you will request the read permissions for personalization when the app starts and the user first logs in. Later, if appropriate, your app can request publish permissions when it intends to post data to Facebook. [...] Asking for the two types separately also greatly improves the chances that users will grant the publish permissions, since your app will only seek them at the time it needs them, most likely when the user has a stronger intent.".</p> <p><strong>4. Sample Code</strong><br> The following sample code should work on iOS and Mac OS X:</p> <pre><code>ACAccountType * facebookAccountType = [self.accountStore accountTypeWithAccountTypeIdentifier:ACAccountTypeIdentifierFacebook]; // At first, we only ask for the basic read permission NSArray * permissions = @[@"email"]; NSMutableDictionary *dict = [[NSMutableDictionary alloc] initWithObjectsAndKeys:@"My app id here", ACFacebookAppIdKey, permissions, ACFacebookPermissionsKey, ACFacebookAudienceOnlyMe, ACFacebookAudienceKey, nil]; [self.accountStore requestAccessToAccountsWithType:facebookAccountType options:dict completion:^(BOOL granted, NSError *error) { if (granted &amp;&amp; error == nil) { /** * The user granted us the basic read permission. * Now we can ask for more permissions **/ NSArray *readPermissions = @[@"read_stream", @"read_friendlists"]; [dict setObject:readPermissions forKey: ACFacebookPermissionsKey]; [self.accountStore requestAccessToAccountsWithType:facebookAccountType options:dict completion:^(BOOL granted, NSError *error) { if(granted &amp;&amp; error == nil) { /** * We now should have some read permission * Now we may ask for write permissions or * do something else. **/ } else { NSLog(@"error is: %@",[error description]); } }]; } else { NSLog(@"error is: %@",[error description]); } }]; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload