Skip to content

Commit

Permalink
Merge pull request #65 from BranchMetrics/fix/ios-unexpected-identifi…
Browse files Browse the repository at this point in the history
…er-error

[FIX] initSession response where the app starts offline
  • Loading branch information
aaustin committed Mar 11, 2016
2 parents a30665d + f0eac10 commit 51b77d2
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 51b77d2

Please sign in to comment.