This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import AuthenticationServices | |
class LoginViewController: UIViewController { | |
let appleLoginBtn = ASAuthorizationAppleIDButton(type: .continue, style: .whiteOutline) | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
appleLoginBtn.cornerRadius = 0 | |
appleLoginBtn.translatesAutoresizingMaskIntoConstraints = false | |
appleLoginBtnContainer.addSubview(appleLoginBtn) | |
appleLoginBtn.topAnchor.constraint(equalTo: appleLoginBtnContainer.topAnchor).isActive = true | |
appleLoginBtn.bottomAnchor.constraint(equalTo: appleLoginBtnContainer.bottomAnchor).isActive = true | |
appleLoginBtn.leftAnchor.constraint(equalTo: appleLoginBtnContainer.leftAnchor).isActive = true | |
appleLoginBtn.rightAnchor.constraint(equalTo: appleLoginBtnContainer.rightAnchor).isActive = true |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func setupEvents() { | |
appleLoginBtn.addTarget(self, action: #selector(appleLogin), for: .touchUpInside) | |
} | |
@objc fileprivate func appleLogin() { | |
let appleIdRequest = ASAuthorizationAppleIDProvider().createRequest() | |
appleIdRequest.requestedScopes = [.email, .fullName] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extension LoginViewController: ASAuthorizationControllerDelegate, | |
ASAuthorizationControllerPresentationContextProviding { | |
func presentationAnchor(for controller: ASAuthorizationController) -> ASPresentationAnchor { | |
return self.view.window! | |
} | |
func authorizationController(controller: ASAuthorizationController, didCompleteWithAuthorization authorization: ASAuthorization) { | |
// TODO | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if let credential = authorization.credential as? ASAuthorizationAppleIDCredential { | |
let userEmail = credential.email ?? "" | |
let familyName = credential.fullName?.familyName ?? "" | |
let givenName = credential.fullName?.givenName ?? "" | |
let userIdentifier = credential.user | |
// 가입/로그인 로직... | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package my.demo | |
import kotlin.text.* | |
// ... |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fun main() { | |
println("Hello world!") | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fun sum(a: Int, b: Int): Int { | |
return a + b | |
} | |
fun main() { | |
print("sum of 3 and 5 is ") | |
println(sum(3, 5)) | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fun sum(a: Int, b: Int) = a + b | |
fun main() { | |
println("sum of 19 and 23 is ${sum(19, 23)}") | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fun printSum(a: Int, b: Int): Unit { // Unit은 생략 가능 | |
println("sum of $a and $b is ${a + b}") | |
} | |
fun main() { | |
printSum(-1, 8) | |
} |
OlderNewer