31
31
// @import FIRTwitterAuthUI;
32
32
#import < FIRTwitterAuthUI.h>
33
33
34
- @interface FIRAuthViewController ()
34
+ @interface FIRAuthViewController () <FIRAuthUIDelegate>
35
35
@property (weak , nonatomic ) IBOutlet UITableViewCell *cellSignIn;
36
36
@property (weak , nonatomic ) IBOutlet UITableViewCell *cellName;
37
37
@property (weak , nonatomic ) IBOutlet UITableViewCell *cellEmail;
@@ -52,6 +52,7 @@ - (void)viewDidLoad {
52
52
53
53
self.auth = [FIRAuth auth ];
54
54
self.authUI = [FIRAuthUI defaultAuthUI ];
55
+ self.authUI .delegate = self;
55
56
}
56
57
57
58
- (void )viewWillAppear : (BOOL )animated {
@@ -111,6 +112,23 @@ - (IBAction)onAuthorization:(id)sender {
111
112
}
112
113
}
113
114
115
+ #pragma mark - FIRAuthUIDelegate methods
116
+
117
+ - (void )authUI : (FIRAuthUI *)authUI didSignInWithUser : (nullable FIRUser *)user error : (nullable NSError *)error {
118
+ if (error) {
119
+ NSError *originalError = error.userInfo [NSUnderlyingErrorKey ];
120
+ UIAlertController *alert = [UIAlertController alertControllerWithTitle: @" Error"
121
+ message: originalError.localizedDescription
122
+ preferredStyle: UIAlertControllerStyleAlert];
123
+ UIAlertAction* closeButton = [UIAlertAction
124
+ actionWithTitle: @" Close"
125
+ style: UIAlertActionStyleDefault
126
+ handler: nil ];
127
+ [alert addAction: closeButton];
128
+ [self presentViewController: alert animated: YES completion: nil ];
129
+ }
130
+ }
131
+
114
132
#pragma mark - Helper Methods
115
133
116
134
// Helper method to retrieve FB app ID from info.plist
0 commit comments