https://github.com/hackergens/loginwithapple
Login With Apple
https://github.com/hackergens/loginwithapple
apple-login apple-login-swiftui ios14 ios14-login login swiftui swiftui-login
Last synced: 27 days ago
JSON representation
Login With Apple
- Host: GitHub
- URL: https://github.com/hackergens/loginwithapple
- Owner: HackerGens
- Created: 2020-12-13T18:22:40.000Z (over 5 years ago)
- Default Branch: main
- Last Pushed: 2020-12-29T07:53:33.000Z (over 5 years ago)
- Last Synced: 2025-09-25T15:05:06.275Z (9 months ago)
- Topics: apple-login, apple-login-swiftui, ios14, ios14-login, login, swiftui, swiftui-login
- Language: Swift
- Homepage:
- Size: 31.3 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Login With Apple in ios 14.You can use this code in swiftui. if you facing any issue comment me below.
VStack {
if #available(iOS 14.0, *) {
SignInWithAppleButton(
.signIn,
onRequest: { request in
// 1
request.requestedScopes = [.fullName, .email]
let appleIDProvider = ASAuthorizationAppleIDProvider()
let request = appleIDProvider.createRequest()
request.requestedScopes = [.fullName, .email]
},
onCompletion: { (result) in
switch result {
case .success(let authorization):
//Handle autorization
if let appleIDCredential = authorization.credential as? ASAuthorizationAppleIDCredential {
let userId = appleIDCredential.user
let identityToken = appleIDCredential.identityToken
let authCode = appleIDCredential.authorizationCode
let email = appleIDCredential.email
let givenName = appleIDCredential.fullName?.givenName
let familyName = appleIDCredential.fullName?.familyName
let state = appleIDCredential.state
print(userId)
print(identityToken)
print(authCode)
print(email)
print(givenName)
print(familyName)
print(state)
// Here you have to send the data to the backend and according to the response let the user get into the app.
}
break
case .failure(let error):
//Handle error
break
}
}
)
} else {
// Fallback on earlier versions
}
}.frame(width:300,height: 60).background(Color.orange.opacity(0.4)).cornerRadius(10).padding([.top], 5)