diff --git a/src/ios/BranchSDK.m b/src/ios/BranchSDK.m index d1b2e17b..12119deb 100644 --- a/src/ios/BranchSDK.m +++ b/src/ios/BranchSDK.m @@ -94,7 +94,14 @@ - (void)initSession:(CDVInvokedUrlCommand*)command } else { NSLog(@"Init Error: %@", [error localizedDescription]); - resultString = [NSString stringWithFormat:@"Init Error: %@", [error localizedDescription]]; + + // We create a JSON string result, because we're getting an error if we directly return a string result. + NSDictionary *errorDict = [NSDictionary dictionaryWithObjectsAndKeys:[error localizedDescription],@"error", nil]; + NSData* errorJSON = [NSJSONSerialization dataWithJSONObject:errorDict + options:NSJSONWritingPrettyPrinted + error:&error]; + + resultString = [[NSString alloc] initWithData:errorJSON encoding:NSUTF8StringEncoding]; } NSLog(@"returning data to js interface.."); [self.commandDelegate evalJs:[NSString stringWithFormat:@"DeepLinkHandler(%@)", resultString]];