@@ -178,22 +178,19 @@ private void removeObservers() {
178178 }
179179
180180 private void removeHandlers () {
181- if (hasAddedInAppMessageClickListener ) {
182- OneSignal .getInAppMessages ().removeClickListener (rnInAppClickListener );
183- hasAddedInAppMessageClickListener = false ;
184- }
185- if (hasAddedInAppMessageLifecycleListener ) {
186- OneSignal .getInAppMessages ().removeLifecycleListener (rnInAppLifecycleListener );
187- hasAddedInAppMessageLifecycleListener = false ;
188- }
189- if (hasAddedNotificationClickListener ) {
190- OneSignal .getNotifications ().removeClickListener (rnNotificationClickListener );
191- hasAddedNotificationClickListener = false ;
192- }
193- if (hasAddedNotificationForegroundListener ) {
194- OneSignal .getNotifications ().removeForegroundLifecycleListener (this );
195- hasAddedNotificationForegroundListener = false ;
181+ if (!oneSignalInitDone ) {
182+ Logging .debug ("OneSignal React-Native SDK not initialized yet. Could not remove handlers." , null );
183+ return ;
196184 }
185+
186+ OneSignal .getInAppMessages ().removeClickListener (rnInAppClickListener );
187+ hasAddedInAppMessageClickListener = false ;
188+ OneSignal .getInAppMessages ().removeLifecycleListener (rnInAppLifecycleListener );
189+ hasAddedInAppMessageLifecycleListener = false ;
190+ OneSignal .getNotifications ().removeClickListener (rnNotificationClickListener );
191+ hasAddedNotificationClickListener = false ;
192+ OneSignal .getNotifications ().removeForegroundLifecycleListener (this );
193+ hasAddedNotificationForegroundListener = false ;
197194 }
198195
199196 private void sendEvent (String eventName , Object params ) {
0 commit comments