简体   繁体   中英

Problems using Facebook SDK on simple IOS app

im trying to use facebook sdk for my IOS 5 app, i got IOS 6 working with UIActivityViewController.

Im using this code to show the login button

            loginview = [[FBLoginView alloc] init];

        loginview.frame = CGRectOffset(loginview.frame, 65, 50);
        [loginview setDelegate:self];   
        loginview.publishPermissions = @[@"publish_actions"];
        loginview.defaultAudience = FBSessionDefaultAudienceFriends;

        [self.view addSubview:loginview];

It shows the button properly, when i click it opens safari and ask me to give permissions to my app, i click yes, then it go back to my app but the button stay with log in text instead the log out text and any of the delegate methods (loginViewFetchedUserInfo, loginViewShowingLoggedInUser,...) gets called.

My code its almost copied from the HelloFacebookSample proyect.

I have the facebook app id and all that things in my plist file.

Im really stuck on this i cant find a solution on google so i came here to ask as my last hope.

Sorry for my bad english and thanks for any help.

change your button title in the

- (void)fbDidLogin

delegate method

Make sure that in your app delegate you have something like this (assuming you have the 3.5 SDK)

- (BOOL)application:(UIApplication *)application
        openURL:(NSURL *)url
  sourceApplication:(NSString *)sourceApplication
     annotation:(id)annotation {
    // attempt to extract a token from the url
    return [FBAppCall handleOpenURL:url sourceApplication:sourceApplication];
}

You need to set it up so that after Safari is shown, your app handles the URL returned and passes it on to the SDK to update the session info and in turn update the login button state.

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