Skip to main content

I am using the React Native SDK and I would like to know the userId of the currently logged in user.

 

Use-case: after updating to the latest SDK, loginUserWithUserAttributes throws an exception when the user is already logged in.

But I have no way to know if the user is already logged into Intercom (after an app restart for example), and if logged it, if it is logged in using the correct user.

 

I could store this in my app, but this makes the code much more complex.

 

The best solution would be to have an Intercom method to return the currently logged user, if any.

Hey @renaud​ ! Is this issue happening only after updating to the latest RN version? Have you installed as per this doc? Can you send us the full error logs?


We're facing the same issue after upgrading the intercom sdk to v4, what's the expected way to fix this? Every time the user re-opens the app this warning is logged, there's no way to know if a user is logged in.

 

Could you guys provide a method in the sdk to know if the user is logged in?


Same here, after upgrading the intercom, this error started happening too many times.

 

We can’t write workarounds for every service we use.

So either we need a method which will return if there is registered user already or this error shouldn’t be thrown by Intercom


I have the same problem. This method should not raise any exception if user is already logged-in or we should have a method that return the currently logged-in user


Same here, I see many people complaning about this. Any comment from the intercom team ?

We really need a way to check if a user is logged in.


Same here. Is there any way to prevent this?


Yeah not having a method to see if a logged in user exists and which user it is, is creating problems for us as well. Sad to see the only response to this issue from Intercom completely ignores the question.


Hey @renaud​ ! Is this issue happening only after updating to the latest RN version? Have you installed as per this doc? Can you send us the full error logs?

@Aparna this hasn’t solved the issue - please can you reply to the original question?


+1 For this issue for us as well.


Friends who use Intercom! I have a workaround. 

Caveat, I’m using Flutter, but I assume the React Native SDK has the same functionality. 

The updateUser function has a StatusCallback with options for onSuccess and onFailure. These can be used check if the user is logged in. Simply make an updateUser request (say a meaningless customAttribute update). You’ll get a success if the user is logged in to Intercom, and a failure if not logged in. 

In my case, I want to login an unidentified user if they’re not already logged. My implementation was: 
 

await Intercom.instance.updateUser(

         customAttributes: {'CheckLogin': Random().nextInt(99999)},

         statusCallback: IntercomStatusCallback(

                    onFailure: (error) async {

                      await Intercom.instance.loginUnidentifiedUser();

                    },

          ));

 

Note, the updateUser call did nothing if the value sent was the same as previous, so I added a randomizer. 


I’m facing the same issue. Without a method to check if a user is logged in, it’s not possible to add this library to an existing production app where users are already logged in, and also have them be logged in to intercom. The only option would be to force users to log out so that they can log in again.

 

Unfortunately the Flutter workaround above doesn’t work as the React Native updateUser() does not have a callback argument. 


Hello,

The new library version 8.1.0 includes the isUserLoggedIn() method, but it always returns true, even when I manually call the loginUnidentifiedUser() method.

Is anyone else experiencing this issue?

Thanks!

 

This might help you fix the issue. Check out the documentation here.


Reply