Iphone facebook连接示例呼叫safari。我不想使用safari

[英]Iphone facebook connect example calls safari. I don't want to use safari

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

Iphone facebook连接示例呼叫safari。我不想使用safari。如何解决这个问题。

9 个解决方案



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...




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.




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...




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

如果用户有iphone的Facebook应用程序,那么它将无法打开safari。它将直接打开Facebook App



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.




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

设置safariAuth:NO [self authorizeWithFBAppAuth:YES safariAuth:NO]; (facebook.m:221)



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.

对于使用较新的Facebook iOS SDK的用户(不确定添加了哪个版本),您可以使用对话框:@“oauth”... method(doc)。正如其他人所说的那样,你放弃了SSO,但是对于像我这样的用例(一个OpenGL游戏),我发现覆盖层更适合切换到另一个应用程序。



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

文件:Facebook.m |开始于:第220行authorizeWithFBAppAuth:safariAuth:|添加布尔值trySafariAuth = NO;到#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...



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];



© 2014-2019 ITdaan.com 粤ICP备14056181号