From 850f1b00d0ab00d0eecfa491c188d51b898eef30 Mon Sep 17 00:00:00 2001 From: Guilherme Ribas Date: Wed, 31 Jan 2024 12:16:32 -0300 Subject: [PATCH] fix: skip handlers removal if SDK is not initialized Signed-off-by: Guilherme Ribas --- .../java/com/onesignal/rnonesignalandroid/RNOneSignal.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/android/src/main/java/com/onesignal/rnonesignalandroid/RNOneSignal.java b/android/src/main/java/com/onesignal/rnonesignalandroid/RNOneSignal.java index 2371169e..d3c12115 100644 --- a/android/src/main/java/com/onesignal/rnonesignalandroid/RNOneSignal.java +++ b/android/src/main/java/com/onesignal/rnonesignalandroid/RNOneSignal.java @@ -165,6 +165,11 @@ private void removeObservers() { } private void removeHandlers() { + if(!oneSignalInitDone) { + Log.i("OneSignal", "OneSignal React-Native SDK not initialized yet. Could not remove handlers."); + return; + } + OneSignal.getInAppMessages().removeClickListener(rnInAppClickListener); hasAddedInAppMessageClickListener = false; OneSignal.getInAppMessages().removeLifecycleListener(rnInAppLifecycleListener);