简体   繁体   中英

Facebook is not login in my app

Hi i am using like feature in my app on Xcode 4.6 in Xib files but on clicking facebook is not login. While on the other side it is login when i do in another app in Story Board. Please guide me if any one knows about it.

- (id)initWithCoder:(NSCoder *)aDecoder {
    if (self = [super initWithCoder:aDecoder]) {
        _facebook = [[Facebook alloc] initWithAppId:@"129649123867187" andDelegate:self];
    }
    return self;
}

- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
    self.facebookLikeView.href = [NSURL URLWithString:@"http://sis.uol.edu.pk/sis/MainForms/login.aspx"];
    self.facebookLikeView.layout = @"button_count";
    self.facebookLikeView.showFaces = NO;
    //    self.facebookLikeView.alpha = 1;
    [self.facebookLikeView load];
    facebookLikeView.delegate = self;
}

#pragma mark FBSessionDelegate methods

- (void)fbDidLogin {
    self.facebookLikeView.alpha = 1;
    [self.facebookLikeView load];
}

- (void)fbDidLogout {
    self.facebookLikeView.alpha = 1;
    [self.facebookLikeView load];
}

#pragma mark FacebookLikeViewDelegate methods

- (void)facebookLikeViewRequiresLogin:(FacebookLikeView *)aFacebookLikeView {
    [_facebook authorize:[NSArray array]];
}

- (void)facebookLikeViewDidRender:(FacebookLikeView *)aFacebookLikeView {
    [UIView beginAnimations:@"" context:nil];
    [UIView setAnimationDelay:0.5];
    self.facebookLikeView.alpha = 1;
    [UIView commitAnimations];
}

- (void)facebookLikeViewDidLike:(FacebookLikeView *)aFacebookLikeView {
    UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Liked"
                                                    message:@"You liked  my app. Thanks!"
                                                   delegate:self
                                          cancelButtonTitle:@"OK"
                                          otherButtonTitles:nil] ;
    [alert show];
}

- (void)facebookLikeViewDidUnlike:(FacebookLikeView *)aFacebookLikeView {
    UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Unliked"
                                                    message:@"You unliked my app ."
                                                   delegate:self
                                          cancelButtonTitle:@"OK"
                                          otherButtonTitles:nil] ;
    [alert show];
}

Your code seems to be OK, and you're using code of FacebookLikeView , when I tried to implement the same in my application it won't show up the login because I forgot to bind FacebookLikeView with IB. Another problem that also happened to me was, You may need to cut _facebook = [[Facebook alloc] initWithAppId:@"129649123867187" andDelegate:self]; line from init method and put it into viewDidLoad like below, because it won't called up in my case!

if(!_facebook)
{
    _facebook = [[Facebook alloc] initWithAppId:@"129649123867187" andDelegate:self];
}

I believe that you don't forget to set delegate for FBConnect , FacebookLikeViewDelegate and FBSessionDelegate

If you still can't solve out the problem, then it may be with your Facebook App ID do try to use the default app id given there in source code, it should work!

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