An open API service indexing awesome lists of open source software.

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

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)