When I logged in by Facebook or Google value of currentUser.providerId is always 'firebase'
currentUser: {
phoneNumber: null,
uid: '...',
providerId: 'firebase',
providerData: [
{
email: '...',
photoURL: '...',
providerId: 'facebook.com',
uid: '...',
displayName: '...'
},
{
email: '...',
photoURL: '...',
providerId: 'google.com',
uid: '...',
displayName: '...'
}
],
displayName: '...',
refreshToken: '...',
email: '...',
isAnonymous: false,
metadata: {
creationTime: 1545114510000,
lastSignInTime: 1545114648000
},
emailVerified: true,
photoURL: ''
}
ios/Podfile:platform :ios, '9.0'
target 'SayblakeApp' do
# Uncomment the next line if you're using Swift or would like to use dynamic frameworks
# use_frameworks!
# RN Pods
pod 'React', :path => '../node_modules/react-native', :subspecs => [
'Core',
'CxxBridge', # Include this for RN >= 0.47
'RCTImage',
'RCTGeolocation'
]
pod 'yoga', :path => '../node_modules/react-native/ReactCommon/yoga'
pod 'DoubleConversion', :podspec => '../node_modules/react-native/third-party-podspecs/DoubleConversion.podspec'
pod 'glog', :podspec => '../node_modules/react-native/third-party-podspecs/glog.podspec'
pod 'Folly', :podspec => '../node_modules/react-native/third-party-podspecs/Folly.podspec'
# Pods for SayblakeApp
pod 'Firebase/Core'
pod 'Firebase/Auth'
pod 'Firebase/Firestore'
pod 'Firebase/Storage'
pod 'Fabric', '~> 1.7.11'
pod 'Crashlytics', '~> 3.10.7'
pod 'Firebase/Performance'
pod 'RNI18n', :path => '../node_modules/react-native-i18n'
pod 'RNImageCropPicker', :path => '../node_modules/react-native-image-crop-picker'
pod 'react-native-fast-image', :path => '../node_modules/react-native-fast-image'
pod 'react-native-maps', :path => '../node_modules/react-native-maps'
pod 'ReactNativePermissions', :path => '../node_modules/react-native-permissions'
pod 'RNDeviceInfo', :path => '../node_modules/react-native-device-info'
pod 'FacebookSDK'
pod 'react-native-fbsdk', :path => '../node_modules/react-native-fbsdk'
pod 'GoogleSignIn'
pod 'RNGoogleSignin', :path => '../node_modules/react-native-google-signin'
target 'SayblakeAppTests' do
inherit! :search_paths
# Pods for testing
end
end
post_install do |installer|
installer.pods_project.targets.each do |target|
if target.name == 'React'
target.remove_from_project
end
end
end
AppDelegate.m:/**
* Copyright (c) 2015-present, Facebook, Inc.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
#import "AppDelegate.h"
#import <React/RCTBundleURLProvider.h>
#import <React/RCTRootView.h>
#import <Firebase.h>
#import <FBSDKCoreKit/FBSDKCoreKit.h>
#import <RNGoogleSignin/RNGoogleSignin.h>
@implementation AppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
NSURL *jsCodeLocation;
jsCodeLocation = [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index" fallbackResource:nil];
RCTRootView *rootView = [[RCTRootView alloc] initWithBundleURL:jsCodeLocation
moduleName:@"SayblakeApp"
initialProperties:nil
launchOptions:launchOptions];
rootView.backgroundColor = [[UIColor alloc] initWithRed:1.0f green:1.0f blue:1.0f alpha:1];
self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
UIViewController *rootViewController = [UIViewController new];
rootViewController.view = rootView;
self.window.rootViewController = rootViewController;
[self.window makeKeyAndVisible];
[FIRApp configure];
[[FBSDKApplicationDelegate sharedInstance] application:application
didFinishLaunchingWithOptions:launchOptions];
return YES;
}
- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url options:(NSDictionary<UIApplicationOpenURLOptionsKey,id> *)options
{
return [[FBSDKApplicationDelegate sharedInstance] application:application openURL:url sourceApplication:options[UIApplicationOpenURLOptionsSourceApplicationKey] annotation:options[UIApplicationOpenURLOptionsAnnotationKey]]
|| [RNGoogleSignin application:application openURL:url sourceApplication:options[UIApplicationOpenURLOptionsSourceApplicationKey] annotation:options[UIApplicationOpenURLOptionsAnnotationKey]];
}
@end
android/build.gradle:// N/A
android/app/build.gradle:// N/A
android/settings.gradle:// N/A
MainApplication.java:// N/A
AndroidManifest.xml:<!-- N/A -->
iOS 12.1 e.g. iOS 10 or Android API 2810.14.1N/AN/AXcode 10 e.g. Xcode 10, Android Studio 3.2React Native version:0.56.0React Native Firebase library version:5.1.0Firebase module(s) you're using that has the issue:TypeScript?N/AExpoKit?ExpoKitN/A
Think react-native-firebase is great? Please consider supporting the project with any of the below:
React Native Firebase and Invertase on TwitterHey, @Baskerville42 thanks for taking the time to fill out this issue correctly. Appreciate it 馃挴
Since a user can sign into their Firebase Authentication account via a connected provider (Google/Facebook etc), the top-level provider id will (usually) be firebase.
But; as you can see in the output of currentUser there is a providerData property that provides information on the specific providers connected to that account. Looping over currentUser.providerData will give you the user.providerId that you're looking for.
If you need to determine the connected provider the user used to sign-in with for the current session on the device then I'd suggest storing this in AsyncStorage as part of your sign-in/signup flow on the device.
Hope this helps.
Thanks
i looking for this so long, thank you so much!!!!
Most helpful comment
Hey, @Baskerville42 thanks for taking the time to fill out this issue correctly. Appreciate it 馃挴
Since a user can sign into their Firebase Authentication account via a connected provider (Google/Facebook etc), the top-level provider id will (usually) be
firebase.But; as you can see in the output of
currentUserthere is aproviderDataproperty that provides information on the specific providers connected to that account. Looping overcurrentUser.providerDatawill give you theuser.providerIdthat you're looking for.If you need to determine the connected provider the user used to sign-in with for the current session on the device then I'd suggest storing this in
AsyncStorageas part of your sign-in/signup flow on the device.Hope this helps.
Thanks