FirebaseUI-iOS icon indicating copy to clipboard operation
FirebaseUI-iOS copied to clipboard

Cannot get providerData values from user object (FIRUserInfoImpl class missing?)

Open yorgosg opened this issue 10 years ago • 2 comments

Hi everyone.

I am having trouble getting the providerData from a user object, post logging in with Facebook.

The providerData as it is returned seems to be an NSArray of FIRUserInfoImpl objects, but I cannot find the FIRUserInfoImpl class anywhere in the FIRAuth files. I tried renaming the FIRUserInfo class to FIRUserInfoImpl just to see if it is what is missing, and it seemed to help for a bit, because with the following command during debugging:

po ((FIRUserInfoImpl *) user.providerData[0]).uid

I managed to print out the values of the first object of the provider data.

However, if I try to use the above in code, the debugger complains that property uid cannot be found in forward class FIRUserInfoImpl, pointing to a forward declaration in FIRAuthProviderUI.h (where I also renamed FIRUserInfo to FIRUserInfoImpl). Btw, I do have the #import FirebaseAuth/FIRUserInfoImpl.h in place.

Please let me know how to get these values from providerData, thanks.

If it helps, I have Cocoapods 1.0.0 and the following pods from Firebase: Using Firebase (3.5.2) Using FirebaseAnalytics (3.3.1) Using FirebaseAuth (3.0.4) Using FirebaseDatabase (3.0.2) Using FirebaseInstanceID (1.0.8) Using FirebaseMessaging (1.1.1) Using FirebaseUI (0.5.5)

yorgosg avatar Sep 15 '16 10:09 yorgosg

Here is code snippet:

#import <FirebaseAuth/FIRUser.h>
#import <FirebaseAuth/FIRUserInfo.h>

.....

NSArray<id<FIRUserInfo>> *providerData = user.providerData;
for (id<FIRUserInfo> userInfo in providerData) {
    NSLog(@"DisplayName: %@ UID: %@", userInfo.displayName, userInfo.uid);
}

BTW in debugger you can just send message without object casting: po [user.providerData[0] uid]

yramanchuk avatar Sep 20 '16 22:09 yramanchuk

Thanks again yramanchuk, that works great! I am closing this issue.

yorgosg avatar Sep 21 '16 18:09 yorgosg