3131// @import FIRTwitterAuthUI;
3232#import < FIRTwitterAuthUI.h>
3333
34- @interface FIRAuthViewController ()
34+ @interface FIRAuthViewController () <FIRAuthUIDelegate>
3535@property (weak , nonatomic ) IBOutlet UITableViewCell *cellSignIn;
3636@property (weak , nonatomic ) IBOutlet UITableViewCell *cellName;
3737@property (weak , nonatomic ) IBOutlet UITableViewCell *cellEmail;
@@ -52,6 +52,7 @@ - (void)viewDidLoad {
5252
5353 self.auth = [FIRAuth auth ];
5454 self.authUI = [FIRAuthUI defaultAuthUI ];
55+ self.authUI .delegate = self;
5556}
5657
5758- (void )viewWillAppear : (BOOL )animated {
@@ -111,6 +112,23 @@ - (IBAction)onAuthorization:(id)sender {
111112 }
112113}
113114
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+
114132#pragma mark - Helper Methods
115133
116134// Helper method to retrieve FB app ID from info.plist
0 commit comments