Skip to content

Commit c6ed239

Browse files
imSzukalaclaude
andauthored
Guard deconstructRegistration against null Registration (#520691) (#451)
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) <noreply@anthropic.com>
1 parent 48ade7d commit c6ed239

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

android/src/main/java/com/intercom/reactnative/IntercomHelpers.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,8 +246,15 @@ public static String getValueAsStringForKey(ReadableMap map, String key) {
246246
return value;
247247
}
248248

249-
public static WritableMap deconstructRegistration(Registration registration) {
249+
public static WritableMap deconstructRegistration(@Nullable Registration registration) {
250250
WritableMap registrationMap = Arguments.createMap();
251+
if (registration == null) {
252+
// Intercom.client().fetchLoggedInUserAttributes() returns null when no user is
253+
// logged in (e.g. after the OS kills and restarts the process, clearing the session).
254+
// Return an empty map to match the iOS bridge, which resolves an empty dictionary
255+
// for the same "no logged-in user" case instead of crashing.
256+
return registrationMap;
257+
}
251258
if (registration.getEmail() != null) {
252259
registrationMap.putString("email", registration.getEmail());
253260
}

0 commit comments

Comments
 (0)