Skip to content

Commit

Permalink
fix notification bug during incoming data call (#1)
Browse files Browse the repository at this point in the history
  • Loading branch information
aelmadani authored Feb 27, 2024
1 parent bffb31f commit aacf9af
Showing 1 changed file with 7 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,13 @@ protected PushNotification(Context context, Bundle bundle, AppLifecycleFacade ap
}

@Override
public void onReceived() throws InvalidNotificationException {
if (!mAppLifecycleFacade.isAppVisible()) {
public void onReceived() {
ReactContext reactContext = mAppLifecycleFacade.getRunningReactContext();
boolean hasActiveCatalystInstance = reactContext != null && reactContext.hasActiveCatalystInstance();
if (!mAppLifecycleFacade.isAppVisible() || !hasActiveCatalystInstance) {
postNotification(null);
notifyReceivedBackgroundToJS();
} else {
}
if (hasActiveCatalystInstance) {
notifyReceivedToJS();
}
}
Expand Down Expand Up @@ -130,17 +132,13 @@ protected void dispatchImmediately() {
}

protected void dispatchUponVisibility() {
mAppLifecycleFacade.addVisibilityListener(getIntermediateAppVisibilityListener());
mAppLifecycleFacade.addVisibilityListener(mAppVisibilityListener);

// Make the app visible so that we'll dispatch the notification opening when visibility changes to 'true' (see
// above listener registration).
launchOrResumeApp();
}

protected AppVisibilityListener getIntermediateAppVisibilityListener() {
return mAppVisibilityListener;
}

protected Notification buildNotification(PendingIntent intent) {
return getNotificationBuilder(intent).build();
}
Expand Down

0 comments on commit aacf9af

Please sign in to comment.