Skip to content

Commit 51b77d2

Browse files
committed
Merge pull request #65 from BranchMetrics/fix/ios-unexpected-identifier-error
[FIX] initSession response where the app starts offline
2 parents a30665d + f0eac10 commit 51b77d2

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/ios/BranchSDK.m

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,14 @@ - (void)initSession:(CDVInvokedUrlCommand*)command
9494
}
9595
else {
9696
NSLog(@"Init Error: %@", [error localizedDescription]);
97-
resultString = [NSString stringWithFormat:@"Init Error: %@", [error localizedDescription]];
97+
98+
// We create a JSON string result, because we're getting an error if we directly return a string result.
99+
NSDictionary *errorDict = [NSDictionary dictionaryWithObjectsAndKeys:[error localizedDescription],@"error", nil];
100+
NSData* errorJSON = [NSJSONSerialization dataWithJSONObject:errorDict
101+
options:NSJSONWritingPrettyPrinted
102+
error:&error];
103+
104+
resultString = [[NSString alloc] initWithData:errorJSON encoding:NSUTF8StringEncoding];
98105
}
99106
NSLog(@"returning data to js interface..");
100107
[self.commandDelegate evalJs:[NSString stringWithFormat:@"DeepLinkHandler(%@)", resultString]];

0 commit comments

Comments
 (0)