7

Parse と Facebook を使用する iOS アプリに取り組んでいます。

Facebook のログインについては、次のページのガイドに従っています: https://www.parse.com/tutorials/integrating-facebook-in-ios

ガイドに従って、キャッシュされたセッションを検証する次のコードがあります。

// check if this cached session is still valid?
// does nothing if still valid
- (void) validateCachedSession
{
    FBRequest *request = [FBRequest requestForMe];
    [request startWithCompletionHandler:^(FBRequestConnection *connection, id result, NSError *error) {
        if (!error)
        {
            // handle successful response
            LogObvious(@"Facebook session validated. No problem");
        }
        else if ([error.userInfo[FBErrorParsedJSONResponseKey][@"body"][@"error"][@"type"] isEqualToString:@"OAuthException"])
        {   // Since the request failed, we can check if it was due to an invalid session
            LogObvious(@"The facebook session was invalidated. Announce logged Out");

            // The persisted session is invalid. Logout!
            [self logout];
        }
        else
        {
            LogObvious(@"The facebook session was invalidated. Announce logged Out");

            // The persisted session is invalid. Logout!
            [self logout];
        }
    }];
}

上記のように、キャッシュされたセッションが無効な場合は、ログアウトを呼び出す必要があります。

- (void) logout
{
    [PFUser logOut];
    // Over here we will show the login button again.
}

これをテストするために。最初に Facebook アカウントを使用してアプリにログインしました。次に、パスワードを変更して、アプリに再度アクセスしました。

アプリは、セッションが無効化され、ログアウトが呼び出されたことを正しく認識します。

しかし、もう一度ログインをクリックすると、ログイン機能が次のエラーを返します。

Uh oh. An error occurred: Error Domain=com.facebook.sdk Code=5 "The operation couldn’t be completed. (com.facebook.sdk error 5.)" UserInfo=0x1e066140 {com.facebook.sdk:ErrorInnerErrorKey=Error Domain=com.apple.accounts Code=1 "Server refused renewal request with error code: 190" UserInfo=0x1d56df10 {NSLocalizedDescription=Server refused renewal request with error code: 190}, com.facebook.sdk:ParsedJSONResponseKey={
    body =     {
        error =         {
            code = 190;
            "error_subcode" = 65001;
        };
    };
}}

なぜ?アプリを終了して再起動しても。アプリはこの状態でスタックし、ログインできなくなります。どんな助けでも大歓迎です。

p/s: 明確にするために、これは私のログイン機能です:

// to be called when user explicitly clicked a login button
- (void) loginByFacebookWithPermissions:(NSArray*)permissionsArray
{
    LogFunctionCalledObvious();
    [PFFacebookUtils logInWithPermissions:permissionsArray block:^(PFUser *user, NSError *error)
    {
        if (!user)
        {
            if (!error)
            {
                NSLog(@"Uh oh. The user cancelled the Facebook login.");
            } else
            {
                NSLog(@"Uh oh. An error occurred: %@", error);
                [self logout];
            }
        } else if (user.isNew)
        {
            LogObvious(@"User with facebook signed up and logged in!");
            [self requestLoggedInUserInfo];
        } else
        {
            LogObvious(@"User with facebook logged in!");
            [self requestLoggedInUserInfo];
        }
    }];
}

p/s2: OK、さらに調査したところ、[設定] -> [Facebook] に移動して新しいパスワードを再入力するまで、この状態のままでした。これは正しい動作ですか?Facebook のパスワードを Facebook.com から変更したとき、iOS6 はすぐにユーザーにパスワードを変更するよう通知すべきではありませんか?

4

1 に答える 1

1

あなたのエラーサブコードはこれを指しています

static const int FBSDKSystemPasswordErrorSubcode = 65001;

case FBSDKSystemPasswordErrorSubcode:
            case FBAuthSubcodePasswordChanged:
                if (subcode == FBSDKSystemPasswordErrorSubcode
                    || [FBErrorUtility fberrorIsErrorFromSystemSession:error]) {
                    userMessageKey = @"FBE:PasswordChangedDevice";
                    userMessageDefault = @"Your Facebook password has changed. To confirm your password, open Settings > Facebook and tap your name.";
                    shouldNotifyUser = YES;
                } else {
                    userMessageKey = @"FBE:PasswordChanged";
                    userMessageDefault = @"Your Facebook password has changed. Please log into this app again to reconnect your Facebook account.";
                }
                break;

これを行うには、何らかの方法でユーザーにメッセージを送信する必要があります

Facebookのパスワードが変更されました。パスワードを確認するには、[設定] > [Facebook] を開き、自分の名前をタップします。

また

Facebookのパスワードが変更されました。このアプリに再度ログインして、Facebook アカウントを再接続してください。

于 2014-03-06T22:15:20.607 に答える