Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/iphone/44.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
iphone sdk中的Facebook签入功能?_Iphone_Ios_Objective C_Xcode_Facebook - Fatal编程技术网

iphone sdk中的Facebook签入功能?

iphone sdk中的Facebook签入功能?,iphone,ios,objective-c,xcode,facebook,Iphone,Ios,Objective C,Xcode,Facebook,我正在我的应用程序中实现签入功能 我得到了参考网址 按照登录方式: - (void) login { permissions = [[NSArray arrayWithObjects: @"user_checkins", @"friends_checkins", @"publish_checkins", nil] retain]; [ facebook authorize:appID permissions:permissions delegate:self]; } 但在我的facebo

我正在我的应用程序中实现签入功能

我得到了参考网址

按照登录方式:

- (void) login {

permissions = [[NSArray arrayWithObjects: @"user_checkins", @"friends_checkins", @"publish_checkins", nil] retain];

[ facebook authorize:appID permissions:permissions delegate:self];
}
但在我的facebook sdk中: “没有支持的方法” [facebook授权:appID权限:权限委托:self];“


请帮助我下载最新的Facebook SDK或提供iphone中签入功能的示例代码???

使用
FacebookSDK
为用户签名需要的不仅仅是一段代码。我不太熟悉您使用的特定构建。但在离开时,用户登录大致如下所示:

- (void)createAndPresentLoginView
{
    if (self.loginViewController == nil) {
        self.loginViewController = [[LoginViewController alloc] initWithNibName:@"LoginViewController"
                                                                           bundle:nil];
        self.navController = [[UINavigationController alloc] initWithRootViewController:self.loginViewController];
        self.window.rootViewController = self.navController;
    }
}

- (void)showLoginView
{
    if (self.loginViewController == nil) {
        [self createAndPresentLoginView];
    } else {
        [self.loginViewController loginFailed];
    }
}

- (void)sessionStateChanged:(FBSession *)session
                      state:(FBSessionState)state
                      error:(NSError *)error
{
    // FBSample logic
    // Any time the session is closed, we want to display the login controller (the user
    // cannot use the application unless they are logged in to Facebook). When the session
    // is opened successfully, hide the login controller and show the main UI.
    switch (state) {
        case FBSessionStateOpen: {
            // For gaining current location
            // [self.mainViewController startLocationManager];
            if (self.loginViewController != nil) {
                [self initializeTabBarController];
                [self.navController pushViewController:self.tabBarController animated:NO];
                self.loginViewController = nil;
            }

            // FBSample logic
            // Pre-fetch and cache the friends for the friend picker as soon as possible to improve
            // responsiveness when the user tags their friends.
            FBCacheDescriptor *cacheDescriptor = [FBFriendPickerViewController cacheDescriptor];
            [cacheDescriptor prefetchAndCacheForSession:session];
        }
            break;
        case FBSessionStateClosed: {
            // FBSample logic
            // Once the user has logged out, we want them to be looking at the root view.
            UIViewController *topViewController = [self.navController topViewController];
            UIViewController *modalViewController = [topViewController presentedViewController];
            if (modalViewController != nil) {
                [topViewController dismissViewControllerAnimated:NO completion:nil];
            }
            [self.navController popToRootViewControllerAnimated:NO];

            [FBSession.activeSession closeAndClearTokenInformation];

            [self performSelector:@selector(showLoginView)
                       withObject:nil
                       afterDelay:0.5f];
        }
            break;
        case FBSessionStateClosedLoginFailed: {
            // if the token goes invalid we want to switch right back to
            // the login view, however we do it with a slight delay in order to
            // account for a race between this and the login view dissappearing
            // a moment before
            [self performSelector:@selector(showLoginView)
                       withObject:nil
                       afterDelay:0.5f];
        }
            break;
        default:
            break;
    }

    [[NSNotificationCenter defaultCenter] postNotificationName:SCSessionStateChangedNotification
                                                        object:session];

    if (error) {
        UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:[NSString stringWithFormat:@"Error: %@",
                                                                     [ShindyAppDelegate FBErrorCodeDescription:error.code]]
                                                            message:error.localizedDescription
                                                           delegate:nil
                                                  cancelButtonTitle:@"OK"
                                                  otherButtonTitles:nil];
        [alertView show];
    }
}

- (BOOL)openSessionWithAllowLoginUI:(BOOL)allowLoginUI
{
    return [FBSession openActiveSessionWithReadPermissions:nil
                                              allowLoginUI:allowLoginUI
                                         completionHandler:^(FBSession *session, FBSessionState state, NSError *error) {
                                             [self sessionStateChanged:session state:state error:error];
                                         }];
}
但是,您仍然需要从Facebook开发者的网站上获取。此外,您还需要获取一个名为
SCSessionStateChangedNotification
的密钥,该密钥特定于您的应用程序

祝你好运