0

アプリにチェックイン機能を実装しています。

参照URLを取得しました

http://tylerwhitedesign.com/how-to-check-in-using-the-facebook-ios-sdk-and-graph-api

ログイン方法による:

- (void) login {

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

[ facebook authorize:appID permissions:permissions delegate:self];
}

しかし、私のfacebook sdkには、「[facebookauthorize:appIDpermissions:permissionsdelegate:self];」をサポートする方法はありません。

最新のFacebookSDKをダウンロードするのを手伝ってください。または、iPhoneのチェックイン機能のサンプルコードを提供してください。

4

1 に答える 1

0

を使用してユーザーにサインインするにはFacebookSDK、コードのブロック以上のものが必要です。私はあなたが使用している特定のビルドにあまり精通していません。しかし、Facebook Developer Documentationから離れると、ユーザーのログインはおおよそ次のようになります。

- (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開発者のWebサイトからFacebookSDKを取得する必要があります。SCSessionStateChangedNotificationまた、アプリケーションに固有のと呼ばれるキーを取得する必要があります。

頑張ってください!

于 2013-01-10T10:39:01.330 に答える