tinycreative / react-native-intercom

React Native wrapper for Intercom.io
MIT License
406 stars 280 forks source link

Not update user's name after login with other user #387

Closed dungvt closed 2 years ago

dungvt commented 4 years ago

Hi everyone, I am using latest version: 17.0.0 and I have an issue when users log out then login with another account. Firstly users login with account1, and I have updated the name in Intercom. It's work fine. After that, users logout and login with account2, I already updated the new one in Intercom. But, when I open the Intercom dashboard, the name still is account1. My code:

function* afterLogin(userInfo) { yield call(Intercom.registerIdentifiedUser, { userId: userInfo.id }); yield call(Intercom.updateUser, { user_id: userInfo.id, email: userInfo.email, name: ${userInfo.firstName} ${userInfo.lastName}, signed_up_at: userInfo.signUpTimestamp / 1000, }); const userHashBuffer = yield call(RNSimpleCrypto.HMAC.hmac256, RNSimpleCrypto.utils.convertUtf8ToArrayBuffer(userInfo.id), RNSimpleCrypto.utils.convertUtf8ToArrayBuffer(CONFIG.INTERCOM.IDENTIFY_VERIFICATION_SECRET)); yield call(Intercom.setUserHash, RNSimpleCrypto.utils.convertArrayBufferToHex(userHashBuffer)); }

function* afterLogout() { yield call(Intercom.logout); }

I found a related topic here: https://community.intercom.com/t/users-not-updated-in-intercom-dashboard-after-login/1389 We still don't have a complete solution, but we have a workaround solution is calling registerUnidentifiedUser after logout. The drawback of this solution is for the first time open the dashboard, the name displayed: 'Hi there'.

Other information: This issue will be solved after restart application or try to close and open the dashboard again.

Thanks for any help.

aibrahim3546 commented 4 years ago

The hacky way im doing currently is by calling the registerIdentifiedUser twice.

e.g on click of a button do this

Intercom.registerIdentifiedUser({ userId: 'bob', name: 'Bob'  }).then({
    Intercom.registerIdentifiedUser({ userId: 'bob', name: 'Bob'  }).then({
        // open the messenger here
    })
})
vgm8 commented 3 years ago

Is there any solution for this?

rifer commented 3 years ago

Hi, any update on this issue? The workarounds aren't working in my case

aibrahim3546 commented 3 years ago

@rifer Try to logout the user first.

Intercom.Logout().then(() => {
    Intercom.registerIdentifiedUser({ userId: 'bob', name: 'Bob'  }).then(() => {
        // open the messenger here
    })
})