4

私は Facebook と統合されたアプリを持っていますが、すべてがうまく動作することもありますが、一部の人が Facebook でログインできないというメールを受け取りました。

今、私は今、何が問題なのか.

Facebook アカウントの設定でログインしていない場合はすべて正常に動作しますが、設定でログインすると、常にsessionStateChangedケースの機能を取得しますFBSessionStateClosedLoginFailed:

私はそれに対して何ができますか?

これが私のコードです:

まず、Facebook でログインをクリックすると、次の関数を使用します。

- (void)facebookLoginFunction {
    if ([self checkInternet]==TRUE) {
        [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(sessionStateChanged:) name:FBSessionStateChangedNotification object:nil];
        AppDelegate *appDelegate = (AppDelegate *)[[UIApplication sharedApplication]delegate];
        // The person using the app has initiated a login, so call the openSession method
        // and show the login UX if necessary.
       [appDelegate openSessionWithAllowLoginUI:YES];
    }
}

デリゲートの関数 sessionStateChanged:

- (void)sessionStateChanged:(FBSession *)session state:(FBSessionState) state error:(NSError *)error{

    switch (state) {
        case FBSessionStateOpen:
            if (!error) {
                // We have a valid session
                NSLog(@"User session found");
            }
        break;
        case FBSessionStateClosed: NSLog(@"User session closed");
        case FBSessionStateClosedLoginFailed:{ NSLog(@"Login failed");
            [FBSession.activeSession closeAndClearTokenInformation];}
        break;
    default:
        break;
    }

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

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

私はこのクレイジーな問題を理解していないので、あなたが私を助けてくれることを本当に願っています. ありがとう

4

1 に答える 1