As shown at WWDC 2020, Apple has made it even easier to implement Apple Sign In. By simply calling the struct
, you will be able to have Apple Sign In right on your screen.
“A control that you add to your interface to allow users to sign in with their Apple ID.” — Apple’s documentation
To follow along with this tutorial, you’ll need some basic knowledge in:
Note: This only supports iOS 14+.
You may indicate if you would like to be a signup or a sign-in. Here, you will be doing a sign-in:
SignInWithAppleButton(
.signIn,
onRequest: { request in
// 1
request.requestedScopes = [.fullName, .email]
},
onCompletion: { result in
switch result {
case .success (let authResults):
// 2
print("Authorization successful.")
case .failure (let error):
// 3
print("Authorization failed: " + error.localizedDescription)
}
}
).frame(width: 200, height: 30)
#ios #swiftui #mobile #swift #programming