Skip to content
This repository was archived by the owner on Jul 28, 2022. It is now read-only.

Commit c39288a

Browse files
fix: Add check for active catalyst instance on react context (#71)
1 parent b607ea6 commit c39288a

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

android/src/main/java/tech/bam/RNBatchPush/RNBatchModule.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import android.content.res.Resources;
77
import android.graphics.Typeface;
88
import android.location.Location;
9+
import android.util.Log;
910

1011
import androidx.annotation.NonNull;
1112
import androidx.annotation.Nullable;
@@ -141,6 +142,11 @@ public void optOutAndWipeData(Promise promise) {
141142
private void sendEvent(ReactContext reactContext,
142143
String eventName,
143144
@Nullable WritableMap params) {
145+
146+
if (!reactContext.hasActiveCatalystInstance()) {
147+
Log.d(NAME, "React context has no active catalyst instance. Aborting send event.");
148+
return;
149+
}
144150
reactContext
145151
.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class)
146152
.emit(eventName, params);

0 commit comments

Comments
 (0)