summaryrefslogtreecommitdiff
path: root/Juick/ViewControllers/LoginViewController.m
diff options
context:
space:
mode:
Diffstat (limited to 'Juick/ViewControllers/LoginViewController.m')
-rw-r--r--Juick/ViewControllers/LoginViewController.m23
1 files changed, 23 insertions, 0 deletions
diff --git a/Juick/ViewControllers/LoginViewController.m b/Juick/ViewControllers/LoginViewController.m
index a0e9b97..de83fa4 100644
--- a/Juick/ViewControllers/LoginViewController.m
+++ b/Juick/ViewControllers/LoginViewController.m
@@ -28,6 +28,7 @@ NSString * const UserChangedNotificationName = @"UserSignedIn";
target:self action:@selector(doneSignIn)];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillHide:) name:UIKeyboardWillHideNotification object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardDidShow:) name:UIKeyboardDidShowNotification object:nil];
+ [self.authorizationField.button addTarget:self action:@selector(signInWithApple) forControlEvents:UIControlEventTouchUpInside];
}
- (void)viewWillAppear:(BOOL)animated {
@@ -64,6 +65,7 @@ NSString * const UserChangedNotificationName = @"UserSignedIn";
- (void)refreshState {
if ([AppDelegate shared].api.currentUser) {
self.title = @"Profile";
+ [self.authorizationField setHidden:YES];
[self.usernameField setHidden:YES];
[self.passwordField setHidden:YES];
[self.currentUser setHidden:NO];
@@ -82,6 +84,7 @@ NSString * const UserChangedNotificationName = @"UserSignedIn";
} else {
self.title = @"Sign in";
self.imageView.image = [UIImage imageNamed:@"Splash"];
+ [self.authorizationField setHidden:NO];
[self.usernameField setHidden:NO];
[self.passwordField setHidden:NO];
[self.currentUser setHidden:YES];
@@ -96,4 +99,24 @@ NSString * const UserChangedNotificationName = @"UserSignedIn";
[[NSNotificationCenter defaultCenter] postNotificationName:UserChangedNotificationName object:nil];
}];
}
+
+- (void)authorizationController:(ASAuthorizationController *)controller didCompleteWithAuthorization:(ASAuthorization *)authorization {
+ NSLog(@"");
+}
+
+- (void)authorizationController:(ASAuthorizationController *)controller didCompleteWithError:(NSError *)error {
+ NSLog(@"");
+}
+
+-(void) signInWithApple {
+ ASAuthorizationAppleIDProvider *appleIDProvider = [ASAuthorizationAppleIDProvider new];
+ ASAuthorizationAppleIDRequest *request = [appleIDProvider createRequest];
+ request.requestedScopes = @[ASAuthorizationScopeFullName, ASAuthorizationScopeEmail];
+
+ ASAuthorizationController *authorizationController = [[ASAuthorizationController alloc] initWithAuthorizationRequests:@[request]];
+ authorizationController.delegate = self;
+ authorizationController.presentationContextProvider = self;
+ [authorizationController performRequests];
+}
+
@end