Take the 2-minute tour ×

I followed this guide and I've created my app successfully with Facebook integration.

What's the problem?

When the user has to do the login, the app quits in the browser (or in Facebook app, if is installed)

How do I keep authentication entirely in-app?

share|improve this question

2 Answers 2

up vote 3 down vote accepted

The point of the oAuth login is that it doesn't happen within your application. It uses fast-app switching to perform the authentication in a trusted environment (either Safari or the Facebook application).

However, you can modify Facebook.m to do the authentication within your application, but you user's credentials will not be remembered. You can see that if your iOS device doesn't support multi-tasking, there is a backup login dialog.

Excerpt from Facebook.m (around line 160):

    if (tryFBAppAuth) {
      NSString *scheme = kFBAppAuthURLScheme;
      if (_localAppId) {
        scheme = [scheme stringByAppendingString:@"2"];
      NSString *fbAppUrl = [FBRequest serializeURL:urlPrefix params:params];

    if (trySafariAuth && !didOpenOtherApp) {
      NSString *nextUrl = [self getOwnBaseUrl];
      [params setValue:nextUrl forKey:@"redirect_uri"];

      NSString *fbAppUrl = [FBRequest serializeURL:loginDialogURL params:params];

// enter his or her credentials
if (!didOpenOtherApp) {
    [_loginDialog release];
    _loginDialog = [[FBLoginDialog alloc] initWithURL:loginDialogURL
    [_loginDialog show];

If you remove the first conditional and it's containing code and set didOpenOtherApp to NO, you can get the behavior you are looking for.

share|improve this answer
thank you!!! really :) –  JAA Aug 7 '11 at 0:53
It's a bit simpler than this (although things may have been different when you answered.) –  bentford Nov 3 '11 at 22:43

To disable this behavior modify Facebook.m line 275 and set both options to NO.

- (void)authorize:(NSArray *)permissions {
  self.permissions = permissions;

  // with both options NO, authorization always happens in-app
  [self authorizeWithFBAppAuth:NO safariAuth:NO];
share|improve this answer

Your Answer


