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

Commit

Permalink
fix: Add check for active catalyst instance on react context (#71)
Browse files Browse the repository at this point in the history
  • Loading branch information
arnaud-roland authored Jan 23, 2022
1 parent b607ea6 commit c39288a
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions android/src/main/java/tech/bam/RNBatchPush/RNBatchModule.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import android.content.res.Resources;
import android.graphics.Typeface;
import android.location.Location;
import android.util.Log;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
Expand Down Expand Up @@ -141,6 +142,11 @@ public void optOutAndWipeData(Promise promise) {
private void sendEvent(ReactContext reactContext,
String eventName,
@Nullable WritableMap params) {

if (!reactContext.hasActiveCatalystInstance()) {
Log.d(NAME, "React context has no active catalyst instance. Aborting send event.");
return;
}
reactContext
.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class)
.emit(eventName, params);
Expand Down

0 comments on commit c39288a

Please sign in to comment.