12
votes

Iphone facebook connect example calls safari. I don't want to use safari. How to fix this problem.

9
Then what do you want to use, Firefox?BoltClock
Thanks very much for this question... I've been banging my head for weeks, I even implemented my own UIWebView that looks 100 times uglier than facebook'sEnrico Susatyo

9 Answers

14
votes

I'm not sure if this is kosher but I commented out lines 131-145 in Facebook.m to pop open a UIWebView instead of opening up the login screen in Safari. Seems to work fine for me...

6
votes

Donkim's suggestion above worked well for me using the 1/31/2011 commit of the SDK. Another option is to look for each call to "authorizeWithFBAppAuth:safariAuth:" in Facebook.m. You can change the second argument from YES to NO on lines 221, 267, and 274.

2
votes

Despite the fact that it open safari and that's ugly, you benefit from the SSO which is a great feature. If any other app is using FBConnect, you user will be automatically connected to yours. And if the facebook app is present, its even better, the login is done through the facebook app and no longer in safari.

So I suggest you keep it that way !

I agree that the whole process should be a bit improved and at least not open a new safari tab every time you connect ! Patience...

2
votes

If user has Facebook application for iphone, then it won't open safari. It will open directly Facebook App

1
votes

The problem with all these solutions is you lose a consistent auth_token. So if you need to do manual graph requests later on in your code by passing the auth_token in the URL, you simply can't.

1
votes

Set safariAuth:NO on [self authorizeWithFBAppAuth:YES safariAuth:NO]; (facebook.m:221)

0
votes

For anyone using a newer Facebook iOS SDK (not sure which version added it), you can use the dialog:@"oauth" ... method (doc). As others have said, you give up SSO, but for use cases like mine (an OpenGL game), I find the overlay preferable to switching to a different app.

0
votes

File: Facebook.m | Starts at: line #220 authorizeWithFBAppAuth:safariAuth: | Add boolean trySafariAuth = NO; to line #223

  /**
   * A private function for opening the authorization dialog.
   */    
   - (void)authorizeWithFBAppAuth:(BOOL)tryFBAppAuth
                        safariAuth:(BOOL)trySafariAuth {

        trySafariAuth = NO;
        // more code allow blow this, but im too lazy to show it
        // so please just change the boolean...
    }
0
votes
Change following method as follows in facebook.m

- (void)authorize:(NSArray *)permissions
             delegate:(id<FBSessionDelegate>)delegate {

      [_permissions release];
      _permissions = [permissions retain];

      _sessionDelegate = delegate;

      [self authorizeWithFBAppAuth:NO safariAuth:NO];
       // [self authorizeWithFBAppAuth:NO safariAuth:YES];
    }