简体   繁体   中英

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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