From f0eac10bb562710985a659eaf7e6f6014a7c3aea Mon Sep 17 00:00:00 2001 From: Renemari Padillo Date: Fri, 11 Mar 2016 12:10:18 +0800 Subject: [PATCH] [FIX] initSession response where the app starts offline --- src/ios/BranchSDK.m | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) 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]];