Skip to content

Commit 525c579

Browse files
authored
Handle loginUserWithUserAttributes with only userId
1 parent ff26a3e commit 525c579

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

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

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -136,12 +136,14 @@ public void loginUserWithUserAttributes(ReadableMap params, Promise promise) {
136136
Boolean hasEmail = params.hasKey("email") && IntercomHelpers.getValueAsStringForKey(params, "email").length() > 0;
137137
Boolean hasUserId = params.hasKey("userId") && IntercomHelpers.getValueAsStringForKey(params, "userId").length() > 0;
138138
Registration registration = null;
139-
String email = IntercomHelpers.getValueAsStringForKey(params, "email");
140139
String userId = IntercomHelpers.getValueAsStringForKey(params, "userId");
141-
if (hasEmail && hasUserId) {
142-
registration = new Registration().withEmail(email).withUserId(userId);
143-
} else if (hasEmail) {
144-
registration = Registration.create().withEmail(email);
140+
if (hasEmail) {
141+
String email = IntercomHelpers.getValueAsStringForKey(params, "email");
142+
if (hasUserId) {
143+
registration = new Registration().withEmail(email).withUserId(userId);
144+
} else {
145+
registration = Registration.create().withEmail(email);
146+
}
145147
} else if (hasUserId) {
146148
registration = Registration.create().withUserId(userId);
147149
} else {

0 commit comments

Comments
 (0)