config-plugin-react-native-intercom icon indicating copy to clipboard operation
config-plugin-react-native-intercom copied to clipboard

Do `Intercom.logout()` on boot in the dev-client?

Open Norfeldt opened this issue 2 years ago • 1 comments

First, this repo is fantastic 🙌 thank you so much!

It allows me to use Intercom together with my expo dev-client. However I have noticed that if I

  1. Sign into Intercom
  2. close the dev-client app
  3. release an intercom carousel
  4. open the dev-client app manually (no deeplink into my app)
  5. then the carousel opens up

Feb-09-2023 18-41-43

In my App.tsx I have an Intercom.logout, but that is not called in the dev-client home screen.

I can't seem to find a solution to trigger Intercom.logout when the app is terminated, but perhaps this plugin can build a

Intercom.logout().catch()

into the boot of the dev-client?

Norfeldt avatar Feb 09 '23 17:02 Norfeldt

I found that I can use the AppState.listener('change', (nextState) => <sign in and out>) for iOS to logout before the user closes the app.

Unlucky this does not work on android. Since closing the app does not cause a AppState "change". Tried listening for the blur but that does not work, since Intercom itself causes the app to blur when showing mobile carousel or conversation.

Is there any way for me to hook into android life-cycle and force a Intercom('shotdown') when the app closes?

Norfeldt avatar Feb 28 '23 08:02 Norfeldt