简体   繁体   English

Facebook SDK登录问题

[英]Facebook SDK issue with login

Using the Hackbook Facebook code I have a problem with the screen just after the user logs in to Facebook. 在用户登录Facebook之后,使用Hackbook Facebook代码我的屏幕出现问题。 Right after the user logs in s/he gets the same pre-login screen. 在用户登录后,他/她将获得相同的登录前屏幕。 When the login button is pressed, s/he get to the correct (showLoggedIn) screen. 按下登录按钮后,将进入正确的(showLoggedIn)屏幕。 See below is the code that is used, but I have yet to figure out the changes necessary. 看到下面是使用的代码,但是我还没有弄清楚必要的更改。

Is there any way in which there is a break in the code to login to Facebook and then after the login sequence (through a browser) to continue to the next sequence (showLoggedIn)? 有什么方法可以中断代码以登录Facebook,然后在登录序列之后(通过浏览器)继续进行下一个序列(showLoggedIn)? Thank you. 谢谢。

- (void)login {
    HackbookAppDelegate *delegate = (HackbookAppDelegate *)[[UIApplication sharedApplication] delegate];
    if (![[delegate facebook] isSessionValid]) {
        [[delegate facebook] authorize:permissions];
    } else {
        [self showLoggedIn];
    }
}

try this Todd 试试这个托德

- (void)login {

// Check and retrieve authorization information
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
if ([defaults objectForKey:@"FBAccessTokenKey"] && [defaults objectForKey:@"FBExpirationDateKey"]) {
    facebook.accessToken = [defaults objectForKey:@"FBAccessTokenKey"];
    facebook.expirationDate = [defaults objectForKey:@"FBExpirationDateKey"];
}
if (![facebook isSessionValid]) {
    facebook.sessionDelegate = self;
    NSArray *permissions = [[NSArray alloc] initWithObjects:
                            @"user_likes", 
                            @"read_stream",
                            //@"user_about_me",
                            //@"email",
                            //@"publish_stream",
                            @"publish_actions", 
                            @"offline_access",
                            nil];
    [facebook authorize:permissions];
    //  [permissions release];
} else {
    [self showLoggedIn];
}
}

i am using ARC thats why i have commented permission release, i hope this serves what you needed 我正在使用ARC,这就是为什么我已评论权限发布的原因,我希望这能满足您的需求

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM