Skip to content

Commit bb6cb03

Browse files
authored
Login user with actual attributes (#149)
* Include passed attrs with loginUserWithUserAttributes * Remove comment
1 parent aaa699b commit bb6cb03

File tree

1 file changed

+2
-9
lines changed

1 file changed

+2
-9
lines changed

ios/IntercomModule.m

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -107,15 +107,8 @@ - (NSData *)dataFromHexString:(NSString *)string {
107107
RCT_EXPORT_METHOD(loginUserWithUserAttributes:(NSDictionary *)userAttributes
108108
success:(RCTPromiseResolveBlock)successCallback
109109
failure:(RCTResponseErrorBlock)failureCallback) {
110-
NSString *userId = userAttributes[@"userId"];
111-
NSString *userEmail = userAttributes[@"email"];
110+
ICMUserAttributes *attributes = [IntercomAttributesBuilder userAttributesForDictionary:userAttributes];
112111

113-
if ([userId isKindOfClass:[NSNumber class]]) {
114-
userId = [(NSNumber *) userId stringValue];
115-
}
116-
ICMUserAttributes *attributes = [ICMUserAttributes new];
117-
attributes.userId = userId;
118-
attributes.email = userEmail;
119112
[Intercom loginUserWithUserAttributes:attributes success:^{
120113
successCallback(@(YES));
121114
} failure:^(NSError * _Nonnull error) {
@@ -203,7 +196,7 @@ - (NSData *)dataFromHexString:(NSString *)string {
203196
selectedSpace = messages;
204197
} else if ([space isEqualToString:@"TICKETS"]) {
205198
selectedSpace = tickets;
206-
}
199+
}
207200
[Intercom presentIntercom:selectedSpace];
208201
RCTLog(@"Presenting Intercom Space : %@", space);
209202
resolve(@(YES));

0 commit comments

Comments
 (0)