11# Welcome to @intercom/intercom-react-native 👋
22
3- [ ![ Version] ( https://img.shields.io/npm/v/intercom-react-native.svg )] ( https://www.npmjs.com/package/intercom-react-native )
3+ [ ![ Version] ( https://img.shields.io/npm/v/@ intercom/intercom -react-native.svg )] ( https://www.npmjs.com/package/@intercom /intercom-react-native )
44[ ![ Documentation] ( https://img.shields.io/badge/documentation-yes-brightgreen.svg )] ( https://github.com/intercom/intercom-react-native#readme )
55[ ![ License: Apache--2.0] ( https://img.shields.io/badge/License-Apache--2.0-yellow.svg )] ( https://github.com/intercom/intercom-react-native#readme )
66[ ![ CircleCi] ( https://circleci.com/gh/intercom/intercom-react-native.svg?style=shield )] ( https://github.com/intercom/intercom-react-native#readme )
@@ -227,12 +227,13 @@ public class MainNotificationService extends FirebaseMessagingService {
227227 /**
228228 * Handle PushNotification
229229 */
230- AppState .addEventListener (
230+ const appStateListener = AppState .addEventListener (
231231 ' change' ,
232232 (nextAppState ) =>
233233 nextAppState === ' active' && Intercom .handlePushMessage ()
234234 );
235- return () => AppState .removeEventListener (' change' , () => true );
235+ return () => AppState .removeEventListener (' change' , () => true ); // <- for RN < 0.65
236+ return () => appStateListener .remove () // <- for RN >= 0.65
236237 }
237238 , [])
238239```
@@ -571,38 +572,6 @@ This takes a push registration token to send to Intercom to enable this device t
571572
572573___
573574
574- ### ` Intercom.addOnMessageCountChangeListener(callback) `
575-
576- Sets a listener that will be notified when the unread conversation count for the registered user changes.
577-
578- ``` javascript
579- useEffect (() => {
580- /**
581- * Handle message count changed
582- */
583- const event = Intercom .addOnMessageCountChangeListener (({count}) => {
584- setCount (count);
585- });
586-
587- return () => {
588- event ();
589- };
590- }, []);
591-
592- ```
593-
594- ### Options
595-
596- | Type | Type | Required |
597- | ------- | -------- | -------- |
598- | callback| function ` ({count: number}) => void ` | yes |
599-
600- ### Returns
601-
602- ` removeEventListener: () => void `
603-
604- ___
605-
606575### ` Intercom.getUnreadConversationCount() `
607576
608577Gets the number of unread conversations for a user.
@@ -621,16 +590,14 @@ Handles the opening of an Intercom push message. This will retrieve the URI from
621590 /**
622591 * Handle PushNotification Open
623592 */
624- AppState .addEventListener (
593+ const appStateListener = AppState .addEventListener (
625594 ' change' ,
626595 (nextAppState ) =>
627596 nextAppState === ' active' && Intercom .handlePushMessage ()
628597 );
629598
630- return () => {
631- AppState .removeEventListener (' change' , () => {
632- });
633- };
599+ return () => AppState .removeEventListener (' change' , () => {}); // <- for RN < 0.65
600+ return () => appStateListener .remove (); // <- for RN >= 0.65
634601}, []);
635602```
636603
0 commit comments