Skip to content

Commit

Permalink
[FIX] initSession response where the app starts offline
Browse files Browse the repository at this point in the history
  • Loading branch information
Renemari Padillo committed Mar 11, 2016
1 parent a30665d commit f0eac10
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/ios/BranchSDK.m
Original file line number Diff line number Diff line change
Expand Up @@ -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]];
Expand Down

0 comments on commit f0eac10

Please sign in to comment.