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()); }