Skip to main content
Answered

Error: Failed to register user. We already have a regsitered user. If you are attempting to register a new user, call logout () before this


Using React Native SDK, I see this error each time I open the app. Here is my code

Intercom.loginUserWithUserAttributes({ userId: `${authData.id}` }).then(() => {
  this.updateUser(authData, onUpdate)
})

 

Even when I wrap this inside logout then callback, I get the same error.

Intercom.logout().then(() => {

  Intercom.loginUserWithUserAttributes({ userId: `${authData.id}` }).then(() => {

    this.updateUser(authData, onUpdate)

  })

})

Note: This happens only on Android.

 

Best answer by Racheal

Hey @hossamnassser938 Racheal from the support engineer team here👋 

 

Are you calling the Intercom.loginUserWithUserAttributes() method multiple times after a user logs into your app? It is expected that you would get that error message, if you called that method multiple times. That method should only be called once, after verification of a login. If any user attributes need to be updated after the user has logged in, you can use the updateUser() method to update them.

 

View original
Did this topic help you find an answer to your question?

3 replies

Racheal
Intercom Team
Forum|alt.badge.img+5
  • Customer Support Engineer
  • 512 replies
  • Answer
  • April 14, 2023

Hey @hossamnassser938 Racheal from the support engineer team here👋 

 

Are you calling the Intercom.loginUserWithUserAttributes() method multiple times after a user logs into your app? It is expected that you would get that error message, if you called that method multiple times. That method should only be called once, after verification of a login. If any user attributes need to be updated after the user has logged in, you can use the updateUser() method to update them.

 


Hey @Racheal Tnx for the reply 😊

 

You’re right. I was calling Intercom.loginUserWithUserAttributes() multiple times. When I fixed that, the issue was fixed. The strange thing is that this does not cause an issue on IOS.


Hello we should have a way to check if the user is logged in. Even if we only call loginUserWithAttributes() once at the login, we need a way to handle already connected users. For instance, if I set a device token in my code on startup of my app, it should be great to first check I’m correctly logged in to Intercom before calling this specific method (which will throw an error in my code if i’m not logged in on Intercom).


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings