Skip to content

Commit 036a4a7

Browse files
imSzukalaclaude
andauthored
fix: pass user attributes during loginUserWithUserAttributes on Android (#391)
* fix: pass user attributes during loginUserWithUserAttributes on Android The Android native module was silently dropping all attributes except email and userId when calling loginUserWithUserAttributes. This chains Registration.withUserAttributes() using the existing buildUserAttributes helper, matching the iOS behavior. Also updates the TypeScript type to accept full UserAttributes instead of only email/userId. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * fix: simplify loginUserWithUserAttributes type to UserAttributes Address PR review feedback: the union type enforcing email|userId at compile time is unnecessary since the native layer validates at runtime. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 8486057 commit 036a4a7

3 files changed

Lines changed: 7 additions & 3 deletions

File tree

android/src/newarch/IntercomModule.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,9 @@ public void loginUserWithUserAttributes(ReadableMap params, Promise promise) {
192192
promise.reject(IntercomErrorCodes.IDENTIFIED_REGISTRATION, "Invalid userId or email");
193193
}
194194
if (registration != null) {
195+
UserAttributes userAttributes = IntercomHelpers.buildUserAttributes(params);
196+
registration.withUserAttributes(userAttributes);
197+
195198
Intercom.client().loginIdentifiedUser(registration, new IntercomStatusCallback() {
196199
@Override
197200
public void onSuccess() {

android/src/oldarch/IntercomModule.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,9 @@ public void loginUserWithUserAttributes(ReadableMap params, Promise promise) {
169169
promise.reject(IntercomErrorCodes.IDENTIFIED_REGISTRATION, "Invalid userId or email");
170170
}
171171
if (registration != null) {
172+
UserAttributes userAttributes = IntercomHelpers.buildUserAttributes(params);
173+
registration.withUserAttributes(userAttributes);
174+
172175
Intercom.client().loginIdentifiedUser(registration, new IntercomStatusCallback() {
173176
@Override
174177
public void onSuccess() {

src/index.tsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,9 +101,7 @@ export type IntercomType = {
101101
* Valid identifiers are `userId` and `email` which must be set in the {@link UserAttributes} object.
102102
* @param params The {@link UserAttributes} object that contains the user's `email` or `userId`.
103103
*/
104-
loginUserWithUserAttributes: (
105-
params: Pick<UserAttributes, 'email' | 'userId'>
106-
) => Promise<boolean>;
104+
loginUserWithUserAttributes: (params: UserAttributes) => Promise<boolean>;
107105

108106
/**
109107
* Log a user out of their Intercom session.

0 commit comments

Comments
 (0)