From aaa45cb3b2a79b119657b12b93f37fdee112e4fc Mon Sep 17 00:00:00 2001 From: Irena Szukala Date: Tue, 16 Jun 2026 13:08:35 +0200 Subject: [PATCH] Guard deconstructRegistration against null Registration (#520691) Intercom.client().fetchLoggedInUserAttributes() returns null when no user is logged in (e.g. after the OS kills and restarts the process, clearing the native session). Both the oldarch and newarch IntercomModule pass that return value straight into IntercomHelpers.deconstructRegistration(), which immediately calls registration.getEmail() and throws a fatal NullPointerException on the JS bridge thread. Return an empty map when registration is null, matching the iOS bridge, which resolves an empty dictionary for the same "no logged-in user" case. Co-Authored-By: Claude Opus 4.8 (1M context) --- .../java/com/intercom/reactnative/IntercomHelpers.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/android/src/main/java/com/intercom/reactnative/IntercomHelpers.java b/android/src/main/java/com/intercom/reactnative/IntercomHelpers.java index b40fa86f..39b27f63 100644 --- a/android/src/main/java/com/intercom/reactnative/IntercomHelpers.java +++ b/android/src/main/java/com/intercom/reactnative/IntercomHelpers.java @@ -246,8 +246,15 @@ public static String getValueAsStringForKey(ReadableMap map, String key) { return value; } - public static WritableMap deconstructRegistration(Registration registration) { + public static WritableMap deconstructRegistration(@Nullable Registration registration) { WritableMap registrationMap = Arguments.createMap(); + if (registration == null) { + // Intercom.client().fetchLoggedInUserAttributes() returns null when no user is + // logged in (e.g. after the OS kills and restarts the process, clearing the session). + // Return an empty map to match the iOS bridge, which resolves an empty dictionary + // for the same "no logged-in user" case instead of crashing. + return registrationMap; + } if (registration.getEmail() != null) { registrationMap.putString("email", registration.getEmail()); }