Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

App 79/call before js module fix #5

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
import androidx.core.text.HtmlCompat;

import com.facebook.react.bridge.ReactContext;
import com.wix.reactnativenotifications.Defs;
import com.wix.reactnativenotifications.R;
import com.wix.reactnativenotifications.core.AppLaunchHelper;
import com.wix.reactnativenotifications.core.AppLifecycleFacade;
Expand Down Expand Up @@ -75,11 +74,15 @@ 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);
}
notifyReceivedToJS();
if (hasActiveCatalystInstance) {
notifyReceivedToJS();
}
}

@Override
Expand Down Expand Up @@ -139,17 +142,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 PendingIntent getCTAPendingIntent(int notificationId) {
final Intent cta = new Intent(mContext, ProxyService.class);
mNotificationProps.setId(notificationId);
Expand Down