Skip to content

Commit

Permalink
fix: remove event emitter warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
maciejBudzinskiNG committed Aug 31, 2021
1 parent c1b3feb commit a11e72b
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 4 deletions.
Expand Up @@ -33,6 +33,16 @@ public IntercomEventEmitter(ReactApplicationContext reactContext) {
super(reactContext);
}

@ReactMethod
public void addListener(String eventName) {
// Keep: Required for RN built in Event Emitter Calls.
}

@ReactMethod
public void removeListeners(Integer count) {
// Keep: Required for RN built in Event Emitter Calls.
}

@ReactMethod
public void startEventListener() {
try {
Expand Down
14 changes: 10 additions & 4 deletions example/src/App.tsx
Expand Up @@ -81,7 +81,7 @@ export default function App() {
/**
* Handle PushNotification
*/
AppState.addEventListener(
const appChangeListener = AppState.addEventListener(
'change',
(nextAppState) =>
nextAppState === 'active' && Intercom.handlePushMessage()
Expand All @@ -90,7 +90,7 @@ export default function App() {
/**
* Handle Push Notification deep links
*/
Linking.addEventListener('url', (event) => {
const urlListener = Linking.addEventListener('url', (event) => {
if (event) {
Alert.alert(event.url);
}
Expand All @@ -116,8 +116,14 @@ export default function App() {

return () => {
countListener.remove();
Linking.removeEventListener('url', () => {});
AppState.removeEventListener('change', () => {});

// @ts-ignore - type definitions haven't been updated to 0.65 yet
urlListener.remove(); // <- for RN 0.65+
// Linking.removeEventListener('url', () => {}); <- for RN < 0.65

// @ts-ignore - type definitions haven't been updated to 0.65 yet
appChangeListener.remove(); // <- for RN 0.65+
//AppState.removeEventListener('change', () => {}); <- for RN < 0.65
};
}, []);

Expand Down

0 comments on commit a11e72b

Please sign in to comment.