Skip to content

Commit a45202b

Browse files
committed
Merge pull request #24 from firebase/mm-0.3.1
Support for captive login portal, subspecs, and enums
2 parents 5e00751 + d22dbb3 commit a45202b

25 files changed

+837
-281
lines changed

FirebaseUI.podspec

+18-10
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,29 @@
11
Pod::Spec.new do |s|
22
s.name = "FirebaseUI"
3-
s.version = "0.3.0"
3+
s.version = "0.3.1"
44
s.summary = "UI binding libraries for Firebase."
55
s.homepage = "https://github.com/firebase/FirebaseUI-iOS"
66
s.license = { :type => 'MIT', :file => 'LICENSE' }
77
s.author = { "Firebase" => "[email protected]" }
88
s.social_media_url = "https://twitter.com/firebase"
9-
s.source = { :git => "https://github.com/firebase/FirebaseUI-iOS.git", :tag => 'v0.3.0' }
10-
s.source_files = "FirebaseUI/**/*.{h,m}"
11-
s.resources = "FirebaseUI/**/Resources/*"
12-
s.dependency "Firebase", "~>2.2"
13-
s.dependency "FBSDKCoreKit"
14-
s.dependency "FBSDKLoginKit"
15-
s.dependency "Google/SignIn"
9+
s.source = { :git => "https://github.com/firebase/FirebaseUI-iOS.git", :tag => 'v0.3.1' }
1610
s.platform = :ios
1711
s.ios.deployment_target = "8.0"
18-
s.ios.framework = "UIKit", "Accounts"
12+
s.dependency "Firebase", "~>2.2"
13+
s.ios.framework = "UIKit"
1914
s.xcconfig = { 'FRAMEWORK_SEARCH_PATHS' => '"$(PODS_ROOT)/Firebase"' }
2015
s.requires_arc = true
21-
end
16+
17+
s.subspec 'Core' do |core|
18+
core.source_files = "FirebaseUI/{Core,Util}/**/*.{h,m}"
19+
end
20+
21+
s.subspec 'Auth' do |auth|
22+
auth.source_files = "FirebaseUI/Auth/**/*.{h,m}"
23+
auth.resources = "FirebaseUI/Auth/Resources/*"
24+
auth.dependency "FBSDKCoreKit"
25+
auth.dependency "FBSDKLoginKit"
26+
auth.dependency "Google/SignIn"
27+
auth.ios.framework = "Accounts"
28+
end
29+
end

FirebaseUI.xcodeproj/project.pbxproj

+14-22
Large diffs are not rendered by default.

FirebaseUI/Auth/API/FirebaseAuthConstants.h

+7-8
Original file line numberDiff line numberDiff line change
@@ -36,20 +36,12 @@
3636
#ifndef FirebaseAuthConstants_h
3737
#define FirebaseAuthConstants_h
3838

39-
FOUNDATION_EXPORT NSString *const kFWPRequestType;
40-
41-
FOUNDATION_EXPORT NSString *const kTwitterAuthProvider;
4239
FOUNDATION_EXPORT NSString *const kTwitterApiKey;
4340

44-
FOUNDATION_EXPORT NSString *const kFacebookAuthProvider;
4541
FOUNDATION_EXPORT NSString *const kFacebookAppId;
4642
FOUNDATION_EXPORT NSString *const kFacebookDisplayName;
4743
FOUNDATION_EXPORT NSString *const kFacebookEmailScope;
4844

49-
FOUNDATION_EXPORT NSString *const kGoogleAuthProvider;
50-
51-
FOUNDATION_EXPORT NSString *const kPasswordAuthProvider;
52-
5345
FOUNDATION_EXPORT CGFloat const kHeaderWidth;
5446
FOUNDATION_EXPORT CGFloat const kHeaderHeight;
5547
FOUNDATION_EXPORT CGFloat const kHeaderSpace;
@@ -66,4 +58,11 @@ FOUNDATION_EXPORT CGFloat const kSeparatorWidth;
6658
FOUNDATION_EXPORT CGFloat const kSeparatorHeight;
6759
FOUNDATION_EXPORT CGFloat const kSeparatorSpace;
6860

61+
typedef NS_ENUM(NSInteger, FAuthProvider) {
62+
FAuthProviderFacebook,
63+
FAuthProviderGoogle,
64+
FAuthProviderTwitter,
65+
FAuthProviderPassword
66+
};
67+
6968
#endif /* FirebaseAuthConstants_h */

FirebaseUI/Auth/API/FirebaseAuthProvider.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,10 @@
5454
@property(strong, nonatomic) FAuthData *authData;
5555

5656
/**
57-
* A string which represents the chosen authentication provider.
57+
* An enum which represents the chosen authentication provider.
5858
* See FAuthenticationConstants.h for a full list.
5959
*/
60-
@property(strong, nonatomic) NSString *provider;
60+
@property(nonatomic) FAuthProvider provider;
6161

6262
/**
6363
* FirebaseAuthDelegate delegate to handle all login, logout, and error events

FirebaseUI/Auth/API/FirebaseLoginButton.h

+4-4
Original file line numberDiff line numberDiff line change
@@ -42,15 +42,15 @@
4242
@interface FirebaseLoginButton : UIButton
4343

4444
/**
45-
* A string representing a valid identity provider (see FirebaseAuthConstants.h for a full list).
45+
* An enum representing a valid identity provider (see FirebaseAuthConstants.h for a full list).
4646
*/
47-
@property(strong, nonatomic) NSString *provider;
47+
@property(nonatomic) FAuthProvider provider;
4848

4949
/**
5050
* Creates a button styled for the appropriate provider.
51-
* @param provider A string representing the desired identity provider to log in with
51+
* @param provider An enum representing the desired identity provider to log in with
5252
* @return FirebaseLoginButton
5353
*/
54-
- (instancetype)initWithProvider:(NSString *)provider;
54+
- (instancetype)initWithProvider:(FAuthProvider)provider;
5555

5656
@end

FirebaseUI/Auth/API/FirebaseLoginViewController.h

+15-2
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,11 @@
113113
*/
114114
@property(weak, nonatomic) IBOutlet NSLayoutConstraint *totalHeightConstraint;
115115

116+
/**
117+
* Dismissal callback on success or failure.
118+
*/
119+
@property (nonatomic, copy) void (^dismissCallback)(FAuthData *user, NSError *error);
120+
116121
/**
117122
* The Firebase database reference which to authenticate against.
118123
*/
@@ -157,10 +162,18 @@
157162

158163
/**
159164
* Enables a given identity provider and allows for login and logout actions against it.
160-
* @param provider A string representing the desired identity provider to log in with
165+
* @param provider An enum representing the desired identity provider to log in with
161166
* @return FirebaseLoginViewController
162167
*/
163-
- (instancetype)enableProvider:(NSString *)provider;
168+
- (instancetype)enableProvider:(FAuthProvider)provider;
169+
170+
/**
171+
* Callback that fires when after the controller is dismissed (either on success or on failure).
172+
* If successful, the user field will be populated; if an error occurred the error field will be populated.
173+
* @param callback A block that returns a user on success or an error on failure.
174+
* @return void
175+
*/
176+
- (void)didDismissWithBlock:(void (^)(FAuthData *user, NSError *error))callback;
164177

165178
/**
166179
* Logs the currently authenticated user out of both Firebase and the currently logged in identity

FirebaseUI/Auth/Implementation/FirebaseAuthConstants.m

+1-7
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
2121
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
2222
* EVENT SHALL FIREBASE BE LIABLE FOR ANY DIRECT,
23-
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
23+
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,f
2424
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
2525
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
2626
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
@@ -32,18 +32,12 @@
3232

3333
#import "FirebaseAuthConstants.h"
3434

35-
NSString *const kTwitterAuthProvider = @"twitter";
3635
NSString *const kTwitterApiKey = @"TwitterApiKey";
3736

38-
NSString *const kFacebookAuthProvider = @"facebook";
3937
NSString *const kFacebookAppId = @"FacebookAppID";
4038
NSString *const kFacebookDisplayName = @"FacebookDisplayName";
4139
NSString *const kFacebookEmailScope = @"email";
4240

43-
NSString *const kGoogleAuthProvider = @"google";
44-
45-
NSString *const kPasswordAuthProvider = @"password";
46-
4741
CGFloat const kHeaderWidth = 258.0f;
4842
CGFloat const kHeaderHeight = 60.0f;
4943
CGFloat const kHeaderSpace = 10.0f;

FirebaseUI/Auth/Implementation/FirebaseFacebookAuthProvider.m

+2-2
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ @implementation FirebaseFacebookAuthProvider {
3939
- (instancetype)initWithRef:(Firebase *)ref authDelegate:(id<FirebaseAuthDelegate>)authDelegate {
4040
self = [super initWithRef:ref authDelegate:authDelegate];
4141
if (self) {
42-
self.provider = kFacebookAuthProvider;
42+
self.provider = FAuthProviderFacebook;
4343
[self configureProvider];
4444
}
4545
return self;
@@ -77,7 +77,7 @@ - (void)login {
7777
NSString *accessToken =
7878
[[FBSDKAccessToken currentAccessToken] tokenString];
7979

80-
[self.ref authWithOAuthProvider:kFacebookAuthProvider
80+
[self.ref authWithOAuthProvider:@"facebook"
8181
token:accessToken
8282
withCompletionBlock:^(NSError *error, FAuthData *authData) {
8383
if (error) {

FirebaseUI/Auth/Implementation/FirebaseGoogleAuthProvider.m

+2-2
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ - (instancetype)initWithRef:(Firebase *)ref
3939
uiDelegate:(UIViewController<GIDSignInUIDelegate> *)uiDelegate {
4040
self = [super initWithRef:ref authDelegate:authDelegate];
4141
if (self) {
42-
self.provider = kGoogleAuthProvider;
42+
self.provider = FAuthProviderGoogle;
4343
[self configureProvider];
4444
[GIDSignIn sharedInstance].delegate = self;
4545
[GIDSignIn sharedInstance].uiDelegate = uiDelegate;
@@ -79,7 +79,7 @@ - (void)logout {
7979
- (void)signIn:(GIDSignIn *)signIn
8080
didSignInForUser:(GIDGoogleUser *)user
8181
withError:(NSError *)error {
82-
[self.ref authWithOAuthProvider:kGoogleAuthProvider
82+
[self.ref authWithOAuthProvider:@"google"
8383
token:user.authentication.accessToken
8484
withCompletionBlock:^(NSError *error, FAuthData *authData) {
8585
if (error) {

FirebaseUI/Auth/Implementation/FirebaseLoginButton.m

+55-35
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434

3535
@implementation FirebaseLoginButton
3636

37-
- (instancetype)initWithProvider:(NSString *)provider {
37+
- (instancetype)initWithProvider:(FAuthProvider)provider {
3838
self = [super initWithFrame:CGRectZero];
3939
if (self) {
4040
self.provider = provider;
@@ -45,43 +45,63 @@ - (instancetype)initWithProvider:(NSString *)provider {
4545
return self;
4646
}
4747

48-
- (UIColor *)backgroundColorForProvider:(NSString *)provider {
49-
if ([provider isEqualToString:kGoogleAuthProvider]) {
50-
return [UIColor colorWithRed:221.0f / 255.0f
51-
green:75.0f / 255.0f
52-
blue:57.0f / 255.0f
53-
alpha:255.0f / 255.0f];
54-
} else if ([provider isEqualToString:kFacebookAuthProvider]) {
55-
return [UIColor colorWithRed:59.0f / 255.0f
56-
green:89.0f / 255.0f
57-
blue:152.0f / 255.0f
58-
alpha:255.0f / 255.0f];
59-
} else if ([provider isEqualToString:kTwitterAuthProvider]) {
60-
return [UIColor colorWithRed:0.0f / 255.0f
61-
green:172.0f / 255.0f
62-
blue:237.0f / 255.0f
63-
alpha:255.0f / 255.0f];
64-
} else if ([provider isEqualToString:kPasswordAuthProvider]) {
65-
return [UIColor colorWithRed:22.0f / 255.0f
66-
green:150.0f / 255.0f
67-
blue:243.0f / 255.0f
68-
alpha:255.0f / 255.0f];
69-
} else {
70-
return [UIColor blackColor];
48+
- (UIColor *)backgroundColorForProvider:(FAuthProvider)provider {
49+
switch (provider) {
50+
case FAuthProviderFacebook:
51+
return [UIColor colorWithRed:59.0f / 255.0f
52+
green:89.0f / 255.0f
53+
blue:152.0f / 255.0f
54+
alpha:255.0f / 255.0f];
55+
break;
56+
57+
case FAuthProviderGoogle:
58+
return [UIColor colorWithRed:221.0f / 255.0f
59+
green:75.0f / 255.0f
60+
blue:57.0f / 255.0f
61+
alpha:255.0f / 255.0f];
62+
break;
63+
64+
case FAuthProviderTwitter:
65+
return [UIColor colorWithRed:0.0f / 255.0f
66+
green:172.0f / 255.0f
67+
blue:237.0f / 255.0f
68+
alpha:255.0f / 255.0f];
69+
break;
70+
71+
case FAuthProviderPassword:
72+
return [UIColor colorWithRed:22.0f / 255.0f
73+
green:150.0f / 255.0f
74+
blue:243.0f / 255.0f
75+
alpha:255.0f / 255.0f];
76+
break;
77+
78+
default:
79+
return [UIColor blackColor];
80+
break;
7181
}
7282
}
7383

74-
- (NSString *)titleForProvider:(NSString *)provider {
75-
if ([provider isEqualToString:kGoogleAuthProvider]) {
76-
return @"Google";
77-
} else if ([provider isEqualToString:kFacebookAuthProvider]) {
78-
return @"Facebook";
79-
} else if ([provider isEqualToString:kTwitterAuthProvider]) {
80-
return @"Twitter";
81-
} else if ([provider isEqualToString:kPasswordAuthProvider]) {
82-
return @"Login";
83-
} else {
84-
return @"Unknown Provider";
84+
- (NSString *)titleForProvider:(FAuthProvider)provider {
85+
switch (provider) {
86+
case FAuthProviderFacebook:
87+
return @"Facebook";
88+
break;
89+
90+
case FAuthProviderGoogle:
91+
return @"Google";
92+
break;
93+
94+
case FAuthProviderTwitter:
95+
return @"Twitter";
96+
break;
97+
98+
case FAuthProviderPassword:
99+
return @"Log In";
100+
break;
101+
102+
default:
103+
return @"Unknown Provider";
104+
break;
85105
}
86106
}
87107

0 commit comments

Comments
 (0)