Xcode Facebook登录错误已关闭 [英] Xcode facebook login error CLOSED

查看:95
本文介绍了Xcode Facebook登录错误已关闭的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,我在 http://developers.facebook.com/上阅读和阅读教程.

Hi I was reading and reading tutorials here on http://developers.facebook.com/ .

关于登录Facebook并发布应用程序的Feed,我的问题是我根本无法登录Facebook.

About Login in to Facebook and publish Feed from application, my problem is I cannot login to Facebook at all.

我无法正常工作.很烂,很烦人,对此没有明确的教程/解释.

And I can't get it work. It sucks, annoying, and there is no clear tutorial/explanation about this.

我正在尝试从我的应用程序登录,然后打开Safari浏览器,然后URL就像发疯了一样 闪烁.

Im trying to login from my app, when safari open and then the URL were like going nuts blinking..

我没有收到错误消息,为什么?

And I dont get an error, why?

是否有关于登录的CLEAR教程?

Is there any CLEAR tutorial About Loging in?

它在模拟器上有效,但在设备上无效.

it works GREAT on simulator, but not on the Device.

我目前在Xcode 4.5 Beta上,但在4.4上也无法使用.

Im on Xcode 4.5 beta right now, but it also doesn't work on 4.4.

我需要帮助!

[关闭]

编辑:我已解决问题!我真是愚蠢……我为了登录FB挣扎了7天, 然后我进行了更改(设备上允许使用Cookie ),一切正常!

EDIT: I fixed it! I was so stupid... I was struggling in seven days just to login to FB, then i changed ( Cookies Allowed on the device ), Everything worked PERFECT!

该设备只需要一些cookie..哈哈

Damn that device just needed some cookies.. Lol

推荐答案

大约2周前,我刚刚更新到了最新的FB sdk.这是我完成的方式:

I just updated to the recent FB sdk about 2 weeks ago. Here's the way I've done it:

//FB recommends to put these two in the app delegate in their sample apps but you can place them other places
- (BOOL)openSessionWithAllowLoginUI:(BOOL)allowLoginUI {
    NSArray *permissions = [NSArray arrayWithObjects:@"publish_actions", nil];
    return [FBSession openActiveSessionWithPermissions:permissions
                                          allowLoginUI:allowLoginUI
                                     completionHandler:^(FBSession *session, FBSessionState state, NSError *error) {
                                         NSLog((@"session.state is %d",session.state));
                                         if(session.state==513){
                                             [AppPrefererences sharedAppPrefererences].faceBookLoggedIn=YES;
                                             NSLog((@"facebookLogin pref has been set to yes from inside appDelegate"));
                                         }
                                         else{
                                             [AppPrefererences sharedAppPrefererences].faceBookLoggedIn=NO;
                                         }
                                     }];
}

- (BOOL)application:(UIApplication *)application
            openURL:(NSURL *)url
  sourceApplication:(NSString *)sourceApplication
         annotation:(id)annotation {
    // FBSample logic
    // We need to handle URLs by passing them to FBSession in order for SSO authentication
    // to work.
    return [FBSession.activeSession handleOpenURL:url];
}


    //Then whereever you want to initiate the log in (i use mine in a tableView)
      AppDelegate  *appDelegate =(AppDelegate*) [[UIApplication sharedApplication]delegate];

 if (![appDelegate openSessionWithAllowLoginUI:NO]) {
                    [appDelegate openSessionWithAllowLoginUI:YES];
                    facebookLoginLabel.text=@"Facebook Log Out";
                    [AppPrefererences sharedAppPrefererences].faceBookEnabled=YES;
                }
                else{
                    facebookLoginLabel.text=@"Facebook Log In";
                    [AppPrefererences sharedAppPrefererences].faceBookLoggedIn=NO;
                    [FBSession.activeSession closeAndClearTokenInformation];                    
                }

然后在任何要发布的地方执行以下操作:

And then whererever you want to post you do this:

  [FBRequestConnection startForPostStatusUpdate:@"any thing you want to post"
                                    completionHandler:^(FBRequestConnection *connection, id result, NSError *error){}];

而且,也不要忘记设置FBLoginViewDelegate

And, also don't forget to set the FBLoginViewDelegate

如果您有任何疑问,请告诉我!希望对您有帮助!

Let me know if you have any questions! Hope it helps!

这篇关于Xcode Facebook登录错误已关闭的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆