cmaycumber / config-plugin-react-native-intercom

Expo plugin for adding @intercom/react-native-intercom using expo config plugins
75 stars 39 forks source link

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

Open Norfeldt opened 1 year ago

Norfeldt commented 1 year ago

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 commented 1 year ago

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?