Skip to content
This repository has been archived by the owner on Nov 15, 2022. It is now read-only.

Commit

Permalink
(iOS) Align retrieval of auth provider ID with Android.
Browse files Browse the repository at this point in the history
  • Loading branch information
Dave Alden authored and duncan-c committed May 27, 2020
1 parent 745ae7c commit 000325b
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions src/ios/FirebasePlugin.m
Original file line number Diff line number Diff line change
Expand Up @@ -751,11 +751,13 @@ - (void) extractAndReturnUserInfo:(CDVInvokedUrlCommand *)command {
[userInfo setValue:user.phoneNumber forKey:@"phoneNumber"];
[userInfo setValue:user.photoURL ? user.photoURL.absoluteString : nil forKey:@"photoUrl"];
[userInfo setValue:user.uid forKey:@"uid"];
[userInfo setValue:user.providerID forKey:@"providerId"];
[userInfo setValue:@(user.isAnonymous ? true : false) forKey:@"isAnonymous"];
[user getIDTokenWithCompletion:^(NSString * _Nullable token, NSError * _Nullable error) {
[userInfo setValue:token forKey:@"idToken"];
[self.commandDelegate sendPluginResult:[CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:userInfo] callbackId:command.callbackId];
[user getIDTokenResultWithCompletion:^(FIRAuthTokenResult * _Nullable tokenResult, NSError * _Nullable error) {
[userInfo setValue:tokenResult.signInProvider forKey:@"providerId"];
[self.commandDelegate sendPluginResult:[CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:userInfo] callbackId:command.callbackId];
}];
}];
}

Expand Down Expand Up @@ -1618,28 +1620,27 @@ - (void)executeGlobalJavascript: (NSString*)jsString
- (void)_logError: (NSString*)msg
{
NSLog(@"%@ ERROR: %@", LOG_TAG, msg);
NSString* jsString = [NSString stringWithFormat:@"console.error(\"%@: %@\")", LOG_TAG, [self escapeJavascriptString:msg]];
NSString* jsString = [NSString stringWithFormat:@"console.error(\"%@: %@\")", LOG_TAG, [self escapeDoubleQuotes:msg]];
[self executeGlobalJavascript:jsString];
}

- (void)_logInfo: (NSString*)msg
{
NSLog(@"%@ INFO: %@", LOG_TAG, msg);
NSString* jsString = [NSString stringWithFormat:@"console.info(\"%@: %@\")", LOG_TAG, [self escapeJavascriptString:msg]];
NSString* jsString = [NSString stringWithFormat:@"console.info(\"%@: %@\")", LOG_TAG, [self escapeDoubleQuotes:msg]];
[self executeGlobalJavascript:jsString];
}

- (void)_logMessage: (NSString*)msg
{
NSLog(@"%@ LOG: %@", LOG_TAG, msg);
NSString* jsString = [NSString stringWithFormat:@"console.log(\"%@: %@\")", LOG_TAG, [self escapeJavascriptString:msg]];
NSString* jsString = [NSString stringWithFormat:@"console.log(\"%@: %@\")", LOG_TAG, [self escapeDoubleQuotes:msg]];
[self executeGlobalJavascript:jsString];
}

- (NSString*)escapeJavascriptString: (NSString*)str
- (NSString*)escapeDoubleQuotes: (NSString*)str
{
NSString* result = [str stringByReplacingOccurrencesOfString: @"\"" withString: @"\\\""];
result = [result stringByReplacingOccurrencesOfString: @"\n" withString: @"\\\n"];
NSString *result =[str stringByReplacingOccurrencesOfString: @"\"" withString: @"\\\""];
return result;
}

Expand Down

0 comments on commit 000325b

Please sign in to comment.