Answered

Do I need to call loginIdentifiedUser on every app launch?

  • 23 June 2023
  • 3 replies
  • 223 views

Another way of asking this question is: Is the result of loginIdentifiedUser() persisted across app launches and device reboots?

My assumption is that I only need to call this method once when my user logs in to my app and I need to call logout() when the user logs out. I don’t need to worry about updating a registration each time the app launches.

However, this section in the docs are throwing me off. It asks to call loginIdentifiedUser() twice: Once on successful login (private fun successfulLogin()) and again “anywhere they sign in”. Is this second call supposed to be when we relaunch the app and detect that the user is logged in or not?

icon

Best answer by Racheal 27 June 2023, 03:36

View original

3 replies

Userlevel 4
Badge +5

Hey @Kiran Rao Racheal from the support engineer team here👋 

 

As long as you are not logging out your users every time the app is closed, you do not need to log them back in. The method should only be called when users are signing in (not re-opening the app). I understand how the doc can be a bit confusing though, so let me know if you have any other questions on this!

 

To provide some additional context, if an app is backgrounded for more than 20 seconds and then resumed we treat that as a new 'session' and increment the 'android sessions' or 'ios sessions' data attribute on the user. Unidentified user state is not cleared by the SDK when an app is backgrounded or closed. If you register an unidentified user, start a conversations, close then reopens the app they should still have access to that conversation, and so on.

 

We do recommend that some apps call logout for unidentified mobile users when they're backgrounded though, kiosk style apps are the usual example here where you can't be confident it'll actually be the same person when the app is foregrounded again.

Thanks for the clarification. This was exactly what I was looking for.

@Racheal If we don’t need to re-authenticate identified Intercom users on subsequent sessions, is the Intercom session valid indefinitely?  I don’t see this anywhere in the docs - probably why many people have relatable issues, including us.

https://community.intercom.com/mobile-sdks-24/how-can-i-get-the-currently-logged-in-user-2766

https://community.intercom.com/mobile-sdks-24/error-failed-to-register-user-we-already-have-a-regsitered-user-if-you-are-attempting-to-register-a-new-user-call-logout-before-this-3909

Reply