Skip to content

Commit

Permalink
Return data from apple login in Promise
Browse files Browse the repository at this point in the history
  • Loading branch information
jpalumickas committed Sep 23, 2020
1 parent 7bd4880 commit 29f0ea8
Showing 1 changed file with 18 additions and 4 deletions.
22 changes: 18 additions & 4 deletions main.mm
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,25 @@

AppleLogin *appleLogin = [[AppleLogin alloc] initWithWindow:win];

Napi::Object obj = Napi::Object::New(env);

obj.Set("hello", "world");

NSDictionary *result = [appleLogin initiateLoginProcess:^(NSDictionary * _Nonnull result) {
Napi::Object obj = Napi::Object::New(env);
obj.Set("idToken",
std::string([result objectForKey:@"identityToken"]
? [[result objectForKey:@"identityToken"] UTF8String]
: ""));

obj.Set("firstName",
std::string([result objectForKey:@"firstName"]
? [[result objectForKey:@"firstName"] UTF8String]
: ""));
obj.Set("lastName",
std::string([result objectForKey:@"lastName"]
? [[result objectForKey:@"lastName"] UTF8String]
: ""));
obj.Set("email",
std::string([result objectForKey:@"email"]
? [[result objectForKey:@"email"] UTF8String]
: ""));
deferred.Resolve(obj);
} errorHandler:^(NSError * _Nonnull error) {
// NSString *nsErr = error.localizedDescription;
Expand Down

0 comments on commit 29f0ea8

Please sign in to comment.