Skip to content

Conversation

@jsreynaud
Copy link
Contributor

Should fix non received deviceToken in JS side for Android:
registerRemoteNotificationsRegistered not always called

…w deprecation notice

- get reactContext from new method if received as null (Android)
@stale
Copy link

stale bot commented Jan 31, 2025

This pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the 🏚 stale label Jan 31, 2025
@stale
Copy link

stale bot commented Feb 24, 2025

The issue has been closed for inactivity.

@stale stale bot closed this Feb 24, 2025
@chrisskilton
Copy link

can we get this reopened? just ran into this on react-native 0.79

@mehmetdemiray
Copy link

I created a patch for this PR, but notifications still don’t work on Android. However, registerRemoteNotificationsRegistered is now working.

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 7db6e8d..4552a7b 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
@@ -89,10 +89,14 @@ public class FcmToken implements IFcmToken {
 
     protected void sendTokenToJS() {
         final ReactInstanceManager instanceManager = ((ReactApplication) mAppContext).getReactNativeHost().getReactInstanceManager();
-        final ReactContext reactContext = instanceManager.getCurrentReactContext();
+        ReactContext reactContext = instanceManager.getCurrentReactContext();
+
+        if (reactContext == null) {
+            reactContext = ((ReactApplication) mAppContext).getReactHost().getCurrentReactContext();
+        }
 
         // Note: Cannot assume react-context exists cause this is an async dispatched service.
-        if (reactContext != null && reactContext.hasActiveCatalystInstance()) {
+        if (reactContext != null && reactContext.hasActiveReactInstance()) {
             Bundle tokenMap = new Bundle();
             tokenMap.putString("deviceToken", sToken);
             mJsIOHelper.sendEventToJS(TOKEN_RECEIVED_EVENT_NAME, tokenMap, reactContext);

@DanielEliraz DanielEliraz reopened this Nov 16, 2025
@stale stale bot removed the 🏚 stale label Nov 16, 2025
Copy link
Collaborator

@DanielEliraz DanielEliraz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great, thanks a lot

@DanielEliraz DanielEliraz merged commit 1b71233 into wix:master Nov 16, 2025
1 of 3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants