Skip to content

Commit 593d76c

Browse files
Fix type of promise reject blocks (#208)
1 parent dcb441e commit 593d76c

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

ios/IntercomModule.m

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ + (void)setReactNativeVersion:(NSString *)v;
99
@end
1010

1111
@implementation IntercomModule
12+
NSString *UNIDENTIFIED_REGISTRATION = @"101";
1213
NSString *IDENTIFIED_REGISTRATION = @"102";
1314
NSString *SET_USER_HASH = @"103";
1415
NSString *UPDATE_USER = @"104";
@@ -96,23 +97,23 @@ - (NSData *)dataFromHexString:(NSString *)string {
9697
#pragma mark - User
9798

9899
RCT_EXPORT_METHOD(loginUnidentifiedUser:(RCTPromiseResolveBlock)successCallback
99-
failure:(RCTResponseErrorBlock)failureCallback) {
100+
failure:(RCTPromiseRejectBlock)failureCallback) {
100101
[Intercom loginUnidentifiedUserWithSuccess:^{
101102
successCallback(@(YES));
102103
} failure:^(NSError * _Nonnull error) {
103-
failureCallback([self removeNullUnderlyingError:error]);
104+
failureCallback(UNIDENTIFIED_REGISTRATION, @"Error in loginUnidentifiedUser", [self removeNullUnderlyingError:error]);
104105
}];
105106
};
106107

107108
RCT_EXPORT_METHOD(loginUserWithUserAttributes:(NSDictionary *)userAttributes
108109
success:(RCTPromiseResolveBlock)successCallback
109-
failure:(RCTResponseErrorBlock)failureCallback) {
110+
failure:(RCTPromiseRejectBlock)failureCallback) {
110111
ICMUserAttributes *attributes = [IntercomAttributesBuilder userAttributesForDictionary:userAttributes];
111112

112113
[Intercom loginUserWithUserAttributes:attributes success:^{
113114
successCallback(@(YES));
114115
} failure:^(NSError * _Nonnull error) {
115-
failureCallback([self removeNullUnderlyingError:error]);
116+
failureCallback(IDENTIFIED_REGISTRATION, @"Error in loginUserWithUserAttributes", [self removeNullUnderlyingError:error]);
116117
}];
117118
}
118119

@@ -123,12 +124,12 @@ - (NSData *)dataFromHexString:(NSString *)string {
123124

124125
RCT_EXPORT_METHOD(updateUser:(NSDictionary *)userAttributesDict
125126
resolver:(RCTPromiseResolveBlock)resolve
126-
failureBlock:(RCTResponseErrorBlock)failureCallback) {
127+
failureBlock:(RCTPromiseRejectBlock)failureCallback) {
127128
ICMUserAttributes *userAttributes = [IntercomAttributesBuilder userAttributesForDictionary:userAttributesDict];
128129
[Intercom updateUser:userAttributes success:^{
129130
resolve(@(YES));
130131
} failure:^(NSError * _Nonnull error) {
131-
failureCallback([self removeNullUnderlyingError:error]);
132+
failureCallback(UPDATE_USER, @"Error in updateUser", [self removeNullUnderlyingError:error]);
132133
}];
133134
};
134135

0 commit comments

Comments
 (0)