Skip to content

Commit

Permalink
Merge pull request #120 from mdescalzo/master
Browse files Browse the repository at this point in the history
Fix for Issue #119
  • Loading branch information
walterholohan authored Jul 13, 2023
2 parents b2cb6d6 + 4be0fc7 commit 89e1b53
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 6 deletions.
8 changes: 4 additions & 4 deletions ios/RNWatch/RNWatch.m
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ - (void) session:(WCSession *)session
activationDidCompleteWithState:(WCSessionActivationState)activationState
error:(NSError *)error {
if (error) {
[self dispatchEventWithName:EVENT_ACTIVATION_ERROR body:@{@"error": error}];
[self dispatchEventWithName:EVENT_ACTIVATION_ERROR body:@{@"error": dictionaryFromError(error)}];
}
}

Expand Down Expand Up @@ -500,7 +500,7 @@ - (void) session:(WCSession *)session
[self.session updateApplicationContext:context error:&error];
if (error) {
NSLog(@"Application context update error: %@ %@", error, [error userInfo]);
[self dispatchEventWithName:EVENT_WATCH_APPLICATION_CONTEXT_ERROR body:@{@"context": context, @"error": [error userInfo]}];
[self dispatchEventWithName:EVENT_WATCH_APPLICATION_CONTEXT_ERROR body:@{@"context": context, @"error": dictionaryFromError(error)}];
}
}

Expand All @@ -527,7 +527,7 @@ - (void) session:(WCSession *)session

if (error) {
NSLog(@"Application context recieve error: %@", error);
[self dispatchEventWithName:EVENT_APPLICATION_CONTEXT_RECEIVED_ERROR body:@{@"error": error}];
[self dispatchEventWithName:EVENT_APPLICATION_CONTEXT_RECEIVED_ERROR body:@{@"error": dictionaryFromError(error)}];
} else {
[self dispatchEventWithName:EVENT_APPLICATION_CONTEXT_RECEIVED body:applicationContext];
}
Expand Down Expand Up @@ -575,7 +575,7 @@ - (void) session:(WCSession *)session
- (void)session:(WCSession *)session didFinishUserInfoTransfer:(WCSessionUserInfoTransfer *)userInfoTransfer error:(NSError *)error {
if (error) {
NSLog(@"User info transfer error: %@ %@", error, [error userInfo]);
[self dispatchEventWithName:EVENT_WATCH_USER_INFO_ERROR body:@{@"userInfo": [userInfoTransfer userInfo], @"error": [error userInfo]}];
[self dispatchEventWithName:EVENT_WATCH_USER_INFO_ERROR body:@{@"userInfo": [userInfoTransfer userInfo], @"error": dictionaryFromError(error)}];
}
}

Expand Down
5 changes: 3 additions & 2 deletions ios/RNWatch/util.h
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
double jsTimestamp();
NSString* uuid();
double jsTimestamp(void);
NSString *uuid(void);
NSDictionary *dictionaryFromError(NSError *error);
10 changes: 10 additions & 0 deletions ios/RNWatch/util.m
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,13 @@
CFRelease(uuid);
return uuidString;
}

NSDictionary* dictionaryFromError(NSError *error) {
NSMutableDictionary *result = NSMutableDictionary.new;
result[@"code"] = @(error.code);
result[@"domain"] = error.domain;
if (error.userInfo) {
result[@"userInfo"] = error.userInfo;
}
return (NSDictionary *) result;
}

0 comments on commit 89e1b53

Please sign in to comment.