Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for Issue #119 #120

Merged
merged 2 commits into from
Jul 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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;
}