React native 调用Auth.updateUserAttribute之后,如何从AWS Cognito检索更新的用户属性

React native 调用Auth.updateUserAttribute之后,如何从AWS Cognito检索更新的用户属性,react-native,amazon-cognito,aws-amplify,React Native,Amazon Cognito,Aws Amplify,我在登录或更新用户属性后从AWS Cognito获取最新用户信息时遇到问题 我正在使用aws amplify进行身份验证,注册和登录工作很好 问题出现在我的个人资料页面上。我允许人们注册通知以及更改其个人资料中的其他数据。我已经通过记录响应,验证了在后端和控制台上成功地进行了更改 但是,当我调用Auth.currentAuthenticatedUser()时,我会得到以前缓存的信息 收到成功响应后,如何检索更新的用户属性 async () => { const { em

我在登录或更新用户属性后从AWS Cognito获取最新用户信息时遇到问题

我正在使用aws amplify进行身份验证,注册和登录工作很好

问题出现在我的个人资料页面上。我允许人们注册通知以及更改其个人资料中的其他数据。我已经通过记录响应,验证了在后端和控制台上成功地进行了更改

但是,当我调用Auth.currentAuthenticatedUser()时,我会得到以前缓存的信息

收到成功响应后,如何检索更新的用户属性

    async () => {
      const { email, given_name, family_name, preferred_username, "custom:notifyPredictRemind": customNotifyPredictRemind, "custom:notifyPredictResult": customNotifyPredictResult } = this.state;
      let params = { email, given_name, family_name, preferred_username, "custom:notifyPredictRemind": customNotifyPredictRemind, "custom:notifyPredictResult": customNotifyPredictResult } 
      let updateResult = await Auth.updateUserAttributes(user, params) // returns SUCCESS
      let user = await Auth.currentAuthenticaterUser()
    }

我希望在最后调用currentAuthenticaterUser返回更新的用户信息。你知道我该怎么做吗?谢谢。

解决了这个问题。有一个名为bypassCache的参数,可以传递给currentAuthenticatedUser(),该参数将刷新用户信息。用于初始登录和Cognito配置文件的更新

async () => {
  const { email, given_name, family_name, preferred_username, "custom:notifyPredictRemind": customNotifyPredictRemind, "custom:notifyPredictResult": customNotifyPredictResult } = this.state;
  let params = { email, given_name, family_name, preferred_username, "custom:notifyPredictRemind": customNotifyPredictRemind, "custom:notifyPredictResult": customNotifyPredictResult } 
  let updateResult = await Auth.updateUserAttributes(user, params) // returns SUCCESS
  let user = await Auth.currentAuthenticaterUser({bypassCache: true}) // UPDATED, NOW WORKS
}