From 84ed7e5ac3b8a2d8fdafe1b775b3f356b344cde4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20Rodriguez=20V=C3=A9lez?= Date: Sat, 12 Feb 2022 12:03:10 -0500 Subject: [PATCH] FIX: eventemitter warning iOS --- App.js | 14 +++++++------- ios/EventEmitter.m | 4 ++++ 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/App.js b/App.js index 3f5d4c518..3628b3c94 100644 --- a/App.js +++ b/App.js @@ -39,7 +39,7 @@ import Privacy from './blue_modules/Privacy'; const A = require('./blue_modules/analytics'); const currency = require('./blue_modules/currency'); -const eventEmitter = new NativeEventEmitter(NativeModules.EventEmitter); +const eventEmitter = Platform.OS === 'ios' ? new NativeEventEmitter(NativeModules.EventEmitter) : undefined; const { EventEmitter } = NativeModules; const ClipboardContentType = Object.freeze({ @@ -113,9 +113,9 @@ const App = () => { return () => { Linking.removeEventListener('url', handleOpenURL); AppState.removeEventListener('change', handleAppStateChange); - eventEmitter.removeAllListeners('onNotificationReceived'); - eventEmitter.removeAllListeners('openSettings'); - eventEmitter.removeAllListeners('onUserActivityOpen'); + eventEmitter?.removeAllListeners('onNotificationReceived'); + eventEmitter?.removeAllListeners('openSettings'); + eventEmitter?.removeAllListeners('onUserActivityOpen'); }; // eslint-disable-next-line react-hooks/exhaustive-deps }, []); @@ -144,9 +144,9 @@ const App = () => { When a notification on iOS is shown while the app is on foreground; On willPresent on AppDelegate.m */ - eventEmitter.addListener('onNotificationReceived', onNotificationReceived); - eventEmitter.addListener('openSettings', openSettings); - eventEmitter.addListener('onUserActivityOpen', onUserActivityOpen); + eventEmitter?.addListener('onNotificationReceived', onNotificationReceived); + eventEmitter?.addListener('openSettings', openSettings); + eventEmitter?.addListener('onUserActivityOpen', onUserActivityOpen); }; const popInitialAction = async data => { diff --git a/ios/EventEmitter.m b/ios/EventEmitter.m index e1defbecd..5b0aefdfb 100644 --- a/ios/EventEmitter.m +++ b/ios/EventEmitter.m @@ -22,6 +22,10 @@ RCT_EXPORT_MODULE(); return sharedInstance; } +- (void)removeListeners:(double)count { + +} + - (instancetype)init { sharedInstance = [super init]; return sharedInstance;