为什么用户';s facebook id';ios有什么变化?

为什么用户';s facebook id';ios有什么变化?,ios,facebook,Ios,Facebook,我是整合facebook的新手。到目前为止,我已经实现了登录。我一直在我们的数据库中保存用户id,以便在他们登录时识别他们。但是我今天注意到id变了。如果id发生变化,我可以用什么来识别facebook用户 这是我正在使用的代码,g_fb_id是传递给服务器的id // This method will handle ALL the session state changes in the app - (void)sessionStateChanged:(FBSession *)session

我是整合facebook的新手。到目前为止,我已经实现了登录。我一直在我们的数据库中保存用户id,以便在他们登录时识别他们。但是我今天注意到id变了。如果id发生变化,我可以用什么来识别facebook用户

这是我正在使用的代码,g_fb_id是传递给服务器的id

// This method will handle ALL the session state changes in the app
- (void)sessionStateChanged:(FBSession *)session state:(FBSessionState) state error:(NSError *)error
{
    // If the session was opened successfully
    if (!error && state == FBSessionStateOpen){
        NSLog(@"Session opened");

        // get facebook ID
        [[FBRequest requestForMe] startWithCompletionHandler:^(FBRequestConnection *connection, NSDictionary<FBGraphUser> *user, NSError *error) {
            if (! error) {
                g_fb_id = [user objectForKey:@"id"];
                g_user.birthday=user.birthday;
                g_user.fb_page=[user objectForKey:@"link"];
                g_user.first_name=user.first_name;
                g_user.last_name=user.last_name;
                g_user.email=[user objectForKey:@"email"];
                g_user.gender=[user objectForKey:@"gender"];



                [self fbLoggedIn];
            } else {
                [self fbLoginFailed:@"Login failed !!!"];
            }
        }];
    } else if (state == FBSessionStateClosed || state == FBSessionStateClosedLoginFailed){
        // If the session is closed
    } else {
        // handle errors
        // Clear this token
        [FBSession.activeSession closeAndClearTokenInformation];
        [self fbLoginFailed:@"Login failed !!!"];
    }
}
//此方法将处理应用程序中的所有会话状态更改
-(void)会话状态已更改:(FBSession*)会话状态:(FBSessionState)状态错误:(NSError*)错误
{
//如果会话已成功打开
如果(!error&&state==FBSessionStateOpen){
NSLog(@“会话已打开”);
//获取facebook ID
[[FBRequest requestForMe]startWithCompletionHandler:^(FBRequestConnection*连接,NSDictionary*用户,NSError*错误){
如果(!错误){
g_fb_id=[user objectForKey:@“id”];
g_user.birth=user.birth;
g_user.fb_page=[user objectForKey:@“link”];
g_user.first_name=user.first_name;
g_user.last_name=user.last_name;
g_user.email=[user objectForKey:@“email”];
g_user.gender=[user objectForKey:@“gender”];
[自我记录];
}否则{
[自我登录失败:@“登录失败!!!”;
}
}];
}else if(state==FBSessionStateClosed | | state==FBSessionStateClosedLoginFailed){
//如果会话已关闭
}否则{
//处理错误
//清除此令牌
[FBSession.activeSession closeAndClearTokenInformation];
[自我登录失败:@“登录失败!!!”;
}
}

您是如何注意到id更改的?您是否将id存储在某个地方,如果是,存储在何处以及如何存储?更改id是什么意思?就像你真的打印出id并比较数据库中相应的id一样?是的,我将它们存储在数据库和电话中。所以下次用户登录时,如果他们匹配,我会自动登录。工作正常,直到用户的id更改,不再匹配我的数据库。