react-use-intercom icon indicating copy to clipboard operation
react-use-intercom copied to clipboard

Get Unread Count via Hook

Open amcdnl opened this issue 3 years ago • 5 comments

Feature

It would be great to have the ability to get the unread count via the hook.

const { unreadCount } = useIntercom();

The primary driver behind the request is getting the notification count in a location that is not easy to get from the provider.

I handled this for now using my own context provider but it seems like the library could do this internally pretty easily.

amcdnl avatar May 17 '22 12:05 amcdnl

Hi, thanks for the feature request.

We could possibly integrate this, however, this would mean that we deviate from the "1on1" IntercomJS API mapping. (I'm aware that we deviated from this "1on1" mapping in the past)

Anyway, how did you handle this in your own context provider?

devrnt avatar May 23 '22 19:05 devrnt

I have a global context that I bind events on the IntercomProvider to.

onUnreadCountChange={setNotificationCount}

I can appreciate the sentiment of wanting to be 1:1 - This doesn't change the API - it just provides easier access.

amcdnl avatar May 23 '22 19:05 amcdnl

I have a global context that I bind events on the IntercomProvider to.

onUnreadCountChange={setNotificationCount}

I see, but this will result in being undefined until the event is triggered?

I can appreciate the sentiment of wanting to be 1:1 - This doesn't change the API - it just provides easier access.

Indeed. However, most of the time I can refer to official Intercom docs/fora to resolve an issue, which saves quite some time. Introducing some new functionality/extending the API is a bit more heavy lifting in the sense of answering the issues

devrnt avatar May 23 '22 20:05 devrnt