Skip to content

Commit 0ab66ed

Browse files
committed
Added in a didDismissWithBlock callback to FirebaseLoginViewController
Updated docs to handle different scenerios for login (captive portal, user initiated) Bumped verion to 0.3.1
1 parent 6490211 commit 0ab66ed

File tree

8 files changed

+144
-47
lines changed

8 files changed

+144
-47
lines changed

FirebaseUI.podspec

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
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' }
9+
s.source = { :git => "https://github.com/firebase/FirebaseUI-iOS.git", :tag => 'v0.3.1' }
1010
s.source_files = "FirebaseUI/**/*.{h,m}"
1111
s.resources = "FirebaseUI/**/Resources/*"
1212
s.dependency "Firebase", "~>2.2"

FirebaseUI.xcodeproj/project.pbxproj

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323

2424
/* Begin PBXBuildFile section */
2525
BB372B551B8BE4890046905E /* FirebaseTwitterAuthProvider.m in Sources */ = {isa = PBXBuildFile; fileRef = BB372B541B8BE4890046905E /* FirebaseTwitterAuthProvider.m */; };
26-
BB372B5B1B8CF7DC0046905E /* FirebaseAuthDelegate.h in Headers */ = {isa = PBXBuildFile; fileRef = BB372B5A1B8CF7DC0046905E /* FirebaseAuthDelegate.h */; settings = {ATTRIBUTES = (Public, ); }; };
2726
BB372B601B8D1B580046905E /* FirebaseTwitterAuthProvider.h in Headers */ = {isa = PBXBuildFile; fileRef = BB372B531B8BE4510046905E /* FirebaseTwitterAuthProvider.h */; settings = {ATTRIBUTES = (Public, ); }; };
2827
BB4877901BA8A0C000FD3D4D /* GoogleSignIn.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = BB48778F1BA8A0C000FD3D4D /* GoogleSignIn.framework */; };
2928
BB48779B1BA8A0D600FD3D4D /* Core.h in Headers */ = {isa = PBXBuildFile; fileRef = BB4877931BA8A0D600FD3D4D /* Core.h */; };
@@ -63,6 +62,7 @@
6362
D81496001BF5AF460099AE10 /* FirebaseUI.m in Sources */ = {isa = PBXBuildFile; fileRef = D81495FB1BF5AF460099AE10 /* FirebaseUI.m */; settings = {ASSET_TAGS = (); }; };
6463
D81496061BF5B92C0099AE10 /* FirebasePasswordAuthProvider.m in Sources */ = {isa = PBXBuildFile; fileRef = D81496051BF5B92C0099AE10 /* FirebasePasswordAuthProvider.m */; settings = {ASSET_TAGS = (); }; };
6564
D81496071BF5B9BE0099AE10 /* FirebasePasswordAuthProvider.h in Headers */ = {isa = PBXBuildFile; fileRef = D81496041BF5B9110099AE10 /* FirebasePasswordAuthProvider.h */; settings = {ATTRIBUTES = (Public, ); }; };
65+
D8680D901C0631FD001987EB /* FirebaseAuthDelegate.h in Headers */ = {isa = PBXBuildFile; fileRef = D8680D8F1C0631FD001987EB /* FirebaseAuthDelegate.h */; settings = {ASSET_TAGS = (); }; };
6666
D87943371BF51FF000525DFD /* FirebaseAuthProvider.m in Sources */ = {isa = PBXBuildFile; fileRef = D87943361BF51FF000525DFD /* FirebaseAuthProvider.m */; };
6767
D87943461BF59E1F00525DFD /* FirebaseAuthConstants.h in Headers */ = {isa = PBXBuildFile; fileRef = D879433E1BF5654000525DFD /* FirebaseAuthConstants.h */; settings = {ATTRIBUTES = (Public, ); }; };
6868
D87943471BF59E4F00525DFD /* TwitterAuthDelegate.h in Headers */ = {isa = PBXBuildFile; fileRef = D879433D1BF5593800525DFD /* TwitterAuthDelegate.h */; settings = {ATTRIBUTES = (Public, ); }; };
@@ -97,7 +97,6 @@
9797
/* Begin PBXFileReference section */
9898
BB372B531B8BE4510046905E /* FirebaseTwitterAuthProvider.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = FirebaseTwitterAuthProvider.h; path = Auth/API/FirebaseTwitterAuthProvider.h; sourceTree = "<group>"; };
9999
BB372B541B8BE4890046905E /* FirebaseTwitterAuthProvider.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = FirebaseTwitterAuthProvider.m; path = Auth/Implementation/FirebaseTwitterAuthProvider.m; sourceTree = "<group>"; };
100-
BB372B5A1B8CF7DC0046905E /* FirebaseAuthDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = FirebaseAuthDelegate.h; path = Auth/Implementation/FirebaseAuthDelegate.h; sourceTree = "<group>"; };
101100
BB48778F1BA8A0C000FD3D4D /* GoogleSignIn.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = GoogleSignIn.framework; path = sdk/google_signin_sdk_2_2_0/GoogleSignIn.framework; sourceTree = "<group>"; };
102101
BB4877931BA8A0D600FD3D4D /* Core.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Core.h; sourceTree = "<group>"; };
103102
BB4877941BA8A0D600FD3D4D /* GGLConfiguration.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GGLConfiguration.h; sourceTree = "<group>"; };
@@ -136,6 +135,7 @@
136135
D81495FB1BF5AF460099AE10 /* FirebaseUI.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = FirebaseUI.m; path = Core/Implementation/FirebaseUI.m; sourceTree = "<group>"; };
137136
D81496041BF5B9110099AE10 /* FirebasePasswordAuthProvider.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = FirebasePasswordAuthProvider.h; path = Auth/API/FirebasePasswordAuthProvider.h; sourceTree = "<group>"; };
138137
D81496051BF5B92C0099AE10 /* FirebasePasswordAuthProvider.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = FirebasePasswordAuthProvider.m; path = Auth/Implementation/FirebasePasswordAuthProvider.m; sourceTree = "<group>"; };
138+
D8680D8F1C0631FD001987EB /* FirebaseAuthDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = FirebaseAuthDelegate.h; path = Auth/API/FirebaseAuthDelegate.h; sourceTree = "<group>"; };
139139
D87943361BF51FF000525DFD /* FirebaseAuthProvider.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = FirebaseAuthProvider.m; path = Auth/Implementation/FirebaseAuthProvider.m; sourceTree = "<group>"; };
140140
D879433D1BF5593800525DFD /* TwitterAuthDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = TwitterAuthDelegate.h; path = Auth/API/TwitterAuthDelegate.h; sourceTree = "<group>"; };
141141
D879433E1BF5654000525DFD /* FirebaseAuthConstants.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = FirebaseAuthConstants.h; path = Auth/API/FirebaseAuthConstants.h; sourceTree = "<group>"; };
@@ -185,13 +185,13 @@
185185
BB372B4D1B8BE33A0046905E /* API */ = {
186186
isa = PBXGroup;
187187
children = (
188+
D8680D8F1C0631FD001987EB /* FirebaseAuthDelegate.h */,
188189
BB372B531B8BE4510046905E /* FirebaseTwitterAuthProvider.h */,
189190
BB6AC2131BA06AC300A10461 /* FirebaseFacebookAuthProvider.h */,
190191
BBF6D4191BA1FF9200C644A7 /* FirebaseGoogleAuthProvider.h */,
191192
D81496041BF5B9110099AE10 /* FirebasePasswordAuthProvider.h */,
192193
BBF6D5761BA33AC300C644A7 /* FirebaseAuthProvider.h */,
193194
D879433E1BF5654000525DFD /* FirebaseAuthConstants.h */,
194-
BB372B5A1B8CF7DC0046905E /* FirebaseAuthDelegate.h */,
195195
D879433D1BF5593800525DFD /* TwitterAuthDelegate.h */,
196196
BB62DD091BA6F3A1001BD539 /* FirebaseAppDelegate.h */,
197197
D809A1241BF6FF6C000257AA /* FirebaseLoginViewController.h */,
@@ -351,7 +351,6 @@
351351
BB48779D1BA8A0D600FD3D4D /* GGLContext.h in Headers */,
352352
D87943461BF59E1F00525DFD /* FirebaseAuthConstants.h in Headers */,
353353
D81495F61BF5AF280099AE10 /* FirebaseUI.h in Headers */,
354-
BB372B5B1B8CF7DC0046905E /* FirebaseAuthDelegate.h in Headers */,
355354
BB62DD7A1BA6F84C001BD539 /* FirebaseAppDelegate.h in Headers */,
356355
D81495F41BF5AF280099AE10 /* FirebaseDataSource.h in Headers */,
357356
D81495F51BF5AF280099AE10 /* FirebaseTableViewDataSource.h in Headers */,
@@ -365,6 +364,7 @@
365364
BB4877A01BA8A0D600FD3D4D /* SignIn.h in Headers */,
366365
BB372B601B8D1B580046905E /* FirebaseTwitterAuthProvider.h in Headers */,
367366
BB48779F1BA8A0D600FD3D4D /* GGLContext+SignIn.h in Headers */,
367+
D8680D901C0631FD001987EB /* FirebaseAuthDelegate.h in Headers */,
368368
BBF6D4161BA19CDF00C644A7 /* FirebaseFacebookAuthProvider.h in Headers */,
369369
D809A1271BF6FF6C000257AA /* FirebaseLoginViewController.h in Headers */,
370370
D81496071BF5B9BE0099AE10 /* FirebasePasswordAuthProvider.h in Headers */,

FirebaseUI/Auth/API/FirebaseLoginViewController.h

Lines changed: 13 additions & 0 deletions
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
*/
@@ -162,6 +167,14 @@
162167
*/
163168
- (instancetype)enableProvider:(NSString *)provider;
164169

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;
177+
165178
/**
166179
* Logs the currently authenticated user out of both Firebase and the currently logged in identity
167180
* provider (if any).

FirebaseUI/Auth/Implementation/FirebaseAuthConstants.m

Lines changed: 1 addition & 1 deletion
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

FirebaseUI/Auth/Implementation/FirebaseLoginViewController.m

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ - (instancetype)initWithRef:(Firebase *)ref;
4242
self = [super init];
4343
if (self) {
4444
self.ref = ref;
45+
self.dismissCallback = ^(FAuthData *user, NSError *error){};
4546
_socialProviders = [[NSMutableArray alloc] initWithCapacity:3];
4647
}
4748
return self;
@@ -57,16 +58,19 @@ - (void)viewDidLoad {
5758
self.cancelButton.imageView.tintColor =
5859
[UIColor colorWithRed:158.0f / 255.0f green:158.0f / 255.0f blue:158.0f / 255.0f alpha:1.0f];
5960
[self.cancelButton addTarget:self
60-
action:@selector(dismissViewController)
61+
action:@selector(cancelButtonPressed)
6162
forControlEvents:UIControlEventTouchUpInside];
6263

6364
// If we're already logged in, cancel this
6465
if (_selectedAuthProvider) {
65-
[self dismissViewController];
66+
[self dismissViewControllerWithUser:self.currentUser andError:nil];
6667
}
6768

6869
if (self.passwordAuthProvider == nil && [_socialProviders count] == 0) {
69-
[self dismissViewController]; // Or throw an exception--you need to have at least one provider
70+
NSError *error = [[NSError alloc] initWithDomain:NSStringFromClass(self.class)
71+
code:FAuthenticationErrorInvalidConfiguration
72+
userInfo:nil];
73+
[self dismissViewControllerWithUser:nil andError:error];
7074
}
7175

7276
// Populate email/password view
@@ -154,6 +158,10 @@ - (instancetype)enableProvider:(NSString *)provider {
154158
return self;
155159
}
156160

161+
- (void)didDismissWithBlock:(void (^)(FAuthData *user, NSError *error))callback {
162+
self.dismissCallback = callback;
163+
}
164+
157165
- (void)loginButtonPressed:(id)button {
158166
if ([button isKindOfClass:[FirebaseLoginButton class]]) {
159167
FirebaseLoginButton *loginButton = (FirebaseLoginButton *)button;
@@ -182,8 +190,14 @@ - (FAuthData *)currentUser {
182190
return [self.ref authData];
183191
}
184192

185-
- (void)dismissViewController {
186-
[self dismissViewControllerAnimated:YES completion:nil];
193+
- (void)cancelButtonPressed {
194+
[self dismissViewControllerWithUser:nil andError:nil];
195+
}
196+
197+
- (void)dismissViewControllerWithUser:(FAuthData *)user andError:(NSError *)error {
198+
[self dismissViewControllerAnimated:YES completion:^{
199+
self.dismissCallback(user, error);
200+
}];
187201
}
188202

189203
#pragma mark -
@@ -193,7 +207,7 @@ - (void)authProvider:(id)provider onLogin:(FAuthData *)authData {
193207
_selectedAuthProvider = provider;
194208
self.emailTextField.text = @"";
195209
self.passwordTextField.text = @"";
196-
[self dismissViewController];
210+
[self dismissViewControllerWithUser:authData andError:nil];
197211
}
198212

199213
- (void)authProvider:(id)provider onProviderError:(NSError *)error {

FirebaseUI/Core/Implementation/FirebaseTableViewDataSource.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ @implementation FirebaseTableViewDataSource
4242
- (instancetype)initWithRef:(Firebase *)ref
4343
cellReuseIdentifier:(NSString *)identifier
4444
view:(UITableView *)tableView {
45-
return [self initWithRef:ref
45+
return [self initWithQuery:ref
4646
modelClass:nil
4747
cellClass:nil
4848
cellReuseIdentifier:identifier

0 commit comments

Comments
 (0)