Skip to content

Commit 9f72a57

Browse files
authored
Merge pull request #933 from firebase/morganchen/10
Prepare for FirebaseUI 10
2 parents c0c5774 + 2e33b33 commit 9f72a57

File tree

9 files changed

+180
-263
lines changed

9 files changed

+180
-263
lines changed

FacebookAuth/Podfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ target 'FirebaseFacebookAuthUI' do
99
# The facebook pods generate an unreasonable number of warnings.
1010
inhibit_all_warnings!
1111

12-
pod 'FBSDKLoginKit', '~> 7.0'
12+
pod 'FBSDKLoginKit', '~> 9.0'
1313
pod 'FBSDKCoreKit'
1414

1515
pod 'FirebaseUI/Auth', :path => '../'

FacebookAuth/Podfile.lock

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
PODS:
2-
- FBSDKCoreKit (7.1.1):
3-
- FBSDKCoreKit/Basics (= 7.1.1)
4-
- FBSDKCoreKit/Core (= 7.1.1)
5-
- FBSDKCoreKit/Basics (7.1.1)
6-
- FBSDKCoreKit/Core (7.1.1):
2+
- FBSDKCoreKit (9.0.0):
3+
- FBSDKCoreKit/Basics (= 9.0.0)
4+
- FBSDKCoreKit/Core (= 9.0.0)
5+
- FBSDKCoreKit/Basics (9.0.0)
6+
- FBSDKCoreKit/Core (9.0.0):
77
- FBSDKCoreKit/Basics
8-
- FBSDKLoginKit (7.1.1):
9-
- FBSDKLoginKit/Login (= 7.1.1)
10-
- FBSDKLoginKit/Login (7.1.1):
11-
- FBSDKCoreKit (~> 7.1.1)
8+
- FBSDKLoginKit (9.0.0):
9+
- FBSDKLoginKit/Login (= 9.0.0)
10+
- FBSDKLoginKit/Login (9.0.0):
11+
- FBSDKCoreKit (~> 9.0.0)
1212
- Firebase/Auth (7.4.0):
1313
- Firebase/CoreOnly
1414
- FirebaseAuth (~> 7.4.0)
@@ -61,7 +61,7 @@ PODS:
6161

6262
DEPENDENCIES:
6363
- FBSDKCoreKit
64-
- FBSDKLoginKit (~> 7.0)
64+
- FBSDKLoginKit (~> 9.0)
6565
- FirebaseUI/Auth (from `../`)
6666
- OCMock
6767

@@ -85,20 +85,20 @@ EXTERNAL SOURCES:
8585
:path: "../"
8686

8787
SPEC CHECKSUMS:
88-
FBSDKCoreKit: b46507dc8b8cefed31d644e74d7cc30e2a715ef8
89-
FBSDKLoginKit: 1a61d79e2b25e2fc0d03dccab1e34b38bbdf2546
88+
FBSDKCoreKit: ac6cc500b8e104bb9a4dd20b1527b5d199123c2e
89+
FBSDKLoginKit: e9b6542fdee322333502ab497f628b011dce7d78
9090
Firebase: 09fb40287b6dfc8ee65f726fa0b788719d3f2a07
9191
FirebaseAuth: d8dba8db90a1705ee2493857047282ca4f6e7598
9292
FirebaseCore: 99c06e5a1e8d6952e75cb1f0a6d0b23c0f5ccdcf
9393
FirebaseCoreDiagnostics: 3770093ac4f2be4590fa03cfa1d3a6e5602d4557
94-
FirebaseUI: f0677a1cc235f6da602cbd5c9b5fbbd24544a6b3
94+
FirebaseUI: ea730675a9a97e5282b5ea5c1db9b15dea51e1e2
9595
GoogleDataTransport: 1024b1a4dfbd7a0e92cb20d7e0a6f1fb66b449a4
9696
GoogleUtilities: d866834472f1324d080496bc67ab3ce5d0d46027
9797
GTMSessionFetcher: b3503b20a988c4e20cc189aa798fd18220133f52
9898
nanopb: 59221d7f958fb711001e6a449489542d92ae113e
9999
OCMock: 29f6e52085b4e7d9b075cbf03ed7c3112f82f934
100100
PromisesObjC: 3113f7f76903778cf4a0586bd1ab89329a0b7b97
101101

102-
PODFILE CHECKSUM: bd55467c7e4a99e9a0956db8228918532b9a340f
102+
PODFILE CHECKSUM: 46618b1c5d74d8b0eadcee97838015eab3535a08
103103

104104
COCOAPODS: 1.10.1

FirebaseUI.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ Pod::Spec.new do |s|
109109
facebook.public_header_files = 'FacebookAuth/FirebaseFacebookAuthUI/*.h'
110110
facebook.source_files = 'FacebookAuth/FirebaseFacebookAuthUI/*.{h,m}'
111111
facebook.dependency 'FirebaseUI/Auth'
112-
facebook.dependency 'FBSDKLoginKit', '~> 7.0'
112+
facebook.dependency 'FBSDKLoginKit', '~> 9.0'
113113
facebook.resource_bundle = {
114114
'FirebaseFacebookAuthUI' => ['FacebookAuth/FirebaseFacebookAuthUI/**/*.{png,lproj}']
115115
}

OAuth/FirebaseOAuthUI/FUIOAuth.m

Lines changed: 45 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,8 @@ + (FUIOAuth *)yahooAuthProvider {
191191
}
192192

193193
+ (FUIOAuth *)appleAuthProvider {
194-
return [self appleAuthProviderWithUserInterfaceStyle:UITraitCollection.currentTraitCollection.userInterfaceStyle];
194+
UIUserInterfaceStyle style = UITraitCollection.currentTraitCollection.userInterfaceStyle;
195+
return [self appleAuthProviderWithUserInterfaceStyle:style];
195196
}
196197

197198
+ (FUIOAuth *)appleAuthProviderWithUserInterfaceStyle:(UIUserInterfaceStyle)userInterfaceStyle {
@@ -203,6 +204,12 @@ + (FUIOAuth *)appleAuthProviderWithUserInterfaceStyle:(UIUserInterfaceStyle)user
203204
iconImage = [iconImage imageWithTintColor:[UIColor blackColor]];
204205
buttonColor = [UIColor whiteColor];
205206
buttonTextColor = [UIColor blackColor];
207+
} else if (userInterfaceStyle == UIUserInterfaceStyleLight) {
208+
iconImage = [iconImage imageWithTintColor:[UIColor whiteColor]];
209+
buttonColor = [UIColor blackColor];
210+
buttonTextColor = [UIColor whiteColor];
211+
} else {
212+
iconImage = [iconImage imageWithTintColor:[UIColor whiteColor]];
206213
}
207214
FUIOAuth *provider = [[FUIOAuth alloc] initWithAuthUI:[FUIAuth defaultAuthUI]
208215
providerID:@"apple.com"
@@ -213,7 +220,7 @@ + (FUIOAuth *)appleAuthProviderWithUserInterfaceStyle:(UIUserInterfaceStyle)user
213220
scopes:@[@"name", @"email"]
214221
customParameters:nil
215222
loginHintKey:nil];
216-
provider.buttonAlignment = FUIButtonAlignmentCenter;
223+
provider.buttonAlignment = FUIButtonAlignmentLeading;
217224
provider.buttonTextColor = buttonTextColor;
218225
return provider;
219226
}
@@ -310,13 +317,47 @@ - (BOOL)handleOpenURL:(NSURL *)URL sourceApplication:(nullable NSString *)source
310317

311318
#pragma mark - ASAuthorizationControllerDelegate
312319

320+
+ (NSPersonNameComponentsFormatter *)nameFormatter {
321+
static NSPersonNameComponentsFormatter *nameFormatter;
322+
static dispatch_once_t onceToken;
323+
dispatch_once(&onceToken, ^{
324+
nameFormatter = [[NSPersonNameComponentsFormatter alloc] init];
325+
});
326+
return nameFormatter;
327+
}
328+
313329
- (void)authorizationController:(ASAuthorizationController *)controller didCompleteWithAuthorization:(ASAuthorization *)authorization API_AVAILABLE(ios(13.0)) {
314-
ASAuthorizationAppleIDCredential* appleIDCredential = authorization.credential;
330+
ASAuthorizationAppleIDCredential *appleIDCredential = authorization.credential;
331+
NSData *rawIdentityToken = appleIDCredential.identityToken;
332+
if (rawIdentityToken == nil) {
333+
// It's pretty awful to not have an error when login is unsuccessful, but Apple's docs
334+
// don't provide any useful information here.
335+
// https://developer.apple.com/documentation/authenticationservices/asauthorizationappleidcredential
336+
NSLog(@"Sign in with Apple completed with authorization, but no jwt: %@", authorization);
337+
_providerSignInCompletion(nil, nil, nil, nil);
338+
}
315339
NSString *idToken = [[NSString alloc] initWithData:appleIDCredential.identityToken encoding:NSUTF8StringEncoding];
316340
FIROAuthCredential *credential = [FIROAuthProvider credentialWithProviderID:@"apple.com"
317341
IDToken:idToken
318342
accessToken:nil];
319-
_providerSignInCompletion(credential, nil, nil, nil);
343+
FIRAuthResultCallback result;
344+
NSPersonNameComponents *nameComponents = appleIDCredential.fullName;
345+
if (nameComponents != nil) {
346+
NSPersonNameComponentsFormatter *formatter = [[self class] nameFormatter];
347+
NSString *displayName = [formatter stringFromPersonNameComponents:nameComponents];
348+
NSDictionary *userInfo = @{FIRAuthCredentialDisplayName: displayName};
349+
credential.userInfo = userInfo;
350+
351+
result = ^(FIRUser *_Nullable user,
352+
NSError *_Nullable error) {
353+
if (user != nil) {
354+
FIRUserProfileChangeRequest *displayNameUpdate = [user profileChangeRequest];
355+
displayNameUpdate.displayName = displayName;
356+
[displayNameUpdate commitChangesWithCompletion:^(NSError * _Nullable error) {}];
357+
}
358+
};
359+
}
360+
_providerSignInCompletion(credential, nil, result, nil);
320361
}
321362

322363
- (void)authorizationController:(ASAuthorizationController *)controller didCompleteWithError:(NSError *)error API_AVAILABLE(ios(13.0)) {

PhoneAuth/FirebasePhoneAuthUI/CountryCode/FUICountryCodes.m

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,36 @@ - (FUICountryCodeInfo *)countryCodeInfoAtIndex:(NSInteger)index {
115115

116116
- (FUICountryCodeInfo *)defaultCountryCodeInfo {
117117
// Get the country code based on the information of user's telecommunication carrier provider.
118-
CTCarrier *carrier = [[[CTTelephonyNetworkInfo alloc] init] subscriberCellularProvider];
118+
CTCarrier *carrier;
119+
if (@available(iOS 12, *)) {
120+
NSDictionary *carriers =
121+
[[[CTTelephonyNetworkInfo alloc] init] serviceSubscriberCellularProviders];
122+
// For multi-sim phones, use the current locale to make an educated guess for
123+
// which carrier to use.
124+
NSString *currentCountryCode = [NSLocale currentLocale].countryCode;
125+
for (CTCarrier *provider in carriers.allValues) {
126+
if ([provider isKindOfClass:[CTCarrier class]] &&
127+
[provider.isoCountryCode isEqualToString:currentCountryCode]) {
128+
carrier = provider;
129+
break;
130+
}
131+
}
132+
133+
// If the carrier is still nil, grab a random carrier from the dictionary.
134+
if (carrier == nil) {
135+
for (CTCarrier *provider in carriers.allValues) {
136+
if ([provider isKindOfClass:[CTCarrier class]]) {
137+
carrier = provider;
138+
break;
139+
}
140+
}
141+
}
142+
} else {
143+
#pragma clang diagnostic push
144+
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
145+
carrier = [[[CTTelephonyNetworkInfo alloc] init] subscriberCellularProvider];
146+
#pragma clang diagnostic pop
147+
}
119148
NSString *countryCode = carrier.isoCountryCode ?: [[self class] countryCodeFromDeviceLocale];
120149
FUICountryCodeInfo *countryCodeInfo = [self countryCodeInfoForCode:countryCode];
121150
// If carrier is not available, get the hard coded default country code.

PhoneAuth/FirebasePhoneAuthUI/FUICodeField.m

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,9 @@ - (void)commonInit {
5555
UIView *paddingView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 20, self.bounds.size.height)];
5656
self.leftView = paddingView;
5757
self.leftViewMode = UITextFieldViewModeAlways;
58-
self.textContentType = UITextContentTypeOneTimeCode;
58+
if (@available(iOS 12.0, *)) {
59+
self.textContentType = UITextContentTypeOneTimeCode;
60+
}
5961

6062
// Default values
6163
if (!self.codeLength) {
@@ -72,7 +74,7 @@ - (void)commonInit {
7274
[self updateText];
7375
}
7476

75-
- (UIKeyboardType) keyboardType {
77+
- (UIKeyboardType)keyboardType {
7678
if (@available(iOS 10, *)) {
7779
return UIKeyboardTypeASCIICapableNumberPad;
7880
} else {

0 commit comments

Comments
 (0)