BlueWallet/patches/react-native-notifications+5.2.2.patch
2026-03-16 21:13:23 +00:00

37 lines
2.3 KiB
Diff

diff --git a/node_modules/react-native-notifications/lib/android/app/src/main/java/com/wix/reactnativenotifications/fcm/FcmToken.java b/node_modules/react-native-notifications/lib/android/app/src/main/java/com/wix/reactnativenotifications/fcm/FcmToken.java
index c7bf71c..08022ff 100644
--- a/node_modules/react-native-notifications/lib/android/app/src/main/java/com/wix/reactnativenotifications/fcm/FcmToken.java
+++ b/node_modules/react-native-notifications/lib/android/app/src/main/java/com/wix/reactnativenotifications/fcm/FcmToken.java
@@ -88,15 +88,26 @@ public class FcmToken implements IFcmToken {
}
protected void sendTokenToJS() {
- final ReactInstanceManager instanceManager = ((ReactApplication) mAppContext).getReactNativeHost().getReactInstanceManager();
- ReactContext reactContext = instanceManager.getCurrentReactContext();
+ final ReactApplication reactApplication = (ReactApplication) mAppContext;
+ ReactContext reactContext = null;
- if (reactContext == null) {
- // If the react context is not available, try to get the current context from the react host (RN0.76).
- reactContext = ((ReactApplication) mAppContext).getReactHost().getCurrentReactContext();
+ try {
+ // Bridgeless/new architecture apps expose the current context from ReactHost.
+ reactContext = reactApplication.getReactHost().getCurrentReactContext();
+ } catch (Throwable ignored) {
+ // Older React Native versions may not expose ReactHost.
+ }
+
+ if (reactContext == null) {
+ try {
+ final ReactInstanceManager instanceManager = reactApplication.getReactNativeHost().getReactInstanceManager();
+ reactContext = instanceManager.getCurrentReactContext();
+ } catch (Throwable ignored) {
+ // Bridgeless mode or other configurations may not support ReactInstanceManager access.
+ }
}
// Note: Cannot assume react-context exists cause this is an async dispatched service.
if (reactContext != null && reactContext.hasActiveReactInstance()) {
Bundle tokenMap = new Bundle();
tokenMap.putString("deviceToken", sToken);
mJsIOHelper.sendEventToJS(TOKEN_RECEIVED_EVENT_NAME, tokenMap, reactContext);