Skip to content

Commit

Permalink
fix(android): support invalidate alongside deprecated onCatalystInsta…
Browse files Browse the repository at this point in the history
…nceDestroy

invalidate is the new way to have a hook called when react-native instances are going away, but onCatalystInstanceDestroy is still required for compatibility with older react-native versions
  • Loading branch information
mikehardy authored Sep 13, 2024
1 parent 616fa32 commit 0349ba5
Showing 1 changed file with 10 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,17 @@ public static String getMainComponent(@NonNull String defaultComponent) {
return Notifee.getInstance().getMainComponent(defaultComponent);
}

@Override
// This method was removed upstream in react-native 0.74+, replaced with invalidate
// We will leave this stub here for older react-native versions compatibility
// ...but it will just delegate to the new invalidate method
public void onCatalystInstanceDestroy() {
invalidate();
}

// This method was added in react-native 0.74 as a replacement for onCatalystInstanceDestroy
// It should be marked @Override but that would cause problems in apps using older react-native
// When minimum supported version is 0.74+ add @Override & remove onCatalystInstanceDestroy
public void invalidate() {
NotifeeReactUtils.clearRunningHeadlessTasks();
}

Expand Down

0 comments on commit 0349ba5

Please sign in to comment.