简体   繁体   English

无法在iPhone应用程序中实现Facebook集成

[英]Unable to implement facebook integration in iphone app

I am working on iphone facebook application. 我正在使用iPhone Facebook应用程序。 I am going through facebook connect tutorial on developer.facebbok.com. 我正在通过developer.facebbok.com上的Facebook连接教程。 I did perfectly what mentioned in tutorial. 我做了完美的教程中提到的。 But as per the tutorial there are log in and cancel button showing and in my application only "Okay" button showing on the right side of top bar. 但是根据教程,登录和取消按钮显示,而在我的应用程序中,顶部栏的右侧仅显示“确定”按钮。 What is wrong happening here? 这是怎么了? Flow is like this. 流是这样的。 1. Tap on tableview cell 2. Open facebookcontroller. 1.点击表格视图单元格。2.打开facebookcontroller。 3. In view did load method of facebookcontroller I added tutorial code. 3.考虑到facebookcontroller的加载方法,我添加了教程代码。

MyConnectViewController.m MyConnectViewController.m

- (void)viewDidLoad
{
    [super viewDidLoad];

        facebook = [[Facebook alloc]initWithAppId:@"353076241375240" andDelegate:self];
        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 authorize:nil];


        }


    // Do any additional setup after loading the view, typically from a nib.
}
- (void) fbDidLogout {
    // Remove saved authorization information if it exists
    NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
    if ([defaults objectForKey:@"FBAccessTokenKey"]) {
        [defaults removeObjectForKey:@"FBAccessTokenKey"];
        [defaults removeObjectForKey:@"FBExpirationDateKey"];
        [defaults synchronize];
    }
}
- (void)fbDidLogin {
    NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
    [defaults setObject:[facebook accessToken] forKey:@"FBAccessTokenKey"];
    [defaults setObject:[facebook expirationDate] forKey:@"FBExpirationDateKey"];
    [defaults synchronize];

}

MyConnectAppDelegate.m MyConnectAppDelegate.m

- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url
  sourceApplication:(NSString *)sourceApplication annotation:(id)annotation {
    return [[_viewController facebook] handleOpenURL:url]; 
}

I want to start from login screen of facebook. 我想从facebook的登录屏幕开始。

Use sharekit and make your life a lot easier :-) 使用sharekit ,让您的生活更轻松:-)

happy coding!! 编码愉快!!

The Okay button appears when you are logged in but not authorised. 登录但未经授权时,会出现“确定”按钮。 Try resetting the simulator or logging out Facebook then try again. 尝试重置模拟器或注销Facebook,然后重试。

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

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