In this video you’ll learn now to add Sign in with Apple to your iOS application
so that you can offer users the option to authenticate with their Apple account. You’ll
learn how to enable Sign in with Apple to the app and show the button in the login view.
In this video you’ll learn now to add Sign in with Apple to your iOS application
so that you can offer users the option to authenticate with their Apple account. You’ll
learn how to enable Sign in with Apple to the app and show the button in the login view.
Cinema mode
Mark complete
Download course materials
Sign up/Sign in
With a free Kodeco account you can download source code, track your progress,
bookmark, personalise your learner profile and more!
Previous episode: 2. Add Sign in with Apple to Your Vapor App
Next episode: 4. Connect Your iOS App to Your Vapor App
Get immediate access to this and 4,000+ other videos and books.
Take your career further with a Kodeco Pro subscription. With unlimited access to over 40+ books and
4,000+ professional videos in a single subscription, it's simply the best investment you can make in
your development career.
In this video we’re going to add Sign in with Apple to your iOS app and learn how to show the button on the login screen. Please note that you’ll need an Apple developer account to test this out.
Adding the capability
Open the TILiOS project in Xcode and navigate to the TILiOS target. Change the bundle identifier to something unique to your project. For example, this video will use dev.timc.siwa-demo.TILiOS.
Next click on the Signing & Capabilities tab and select your development team to ensure the app is signed correctly.
Siyijym, slotc av jze obp pid lasotufalz pixfev, teabtd yir Turk us jakq Axmgu enc pulekx ok. Ffol ullatn foe qu omu Nocg og micf Oybve uv beog olz.
Displaying the button
Now that you can do so, it’s time to show the Sign in with Apple button on the log in screen. Open LoginView.swift and at the top of the file, import AuthenticationServices:
import AuthenticationServices
AohrabdivenoirPetwufaq ljunonap e raaqy at maik ner lta Ramj ik qutw Epgfo jijgax. Akfagm ob duseh swe OdqxlYekdun tix Qey As, ezaxv jpa pudlIt riyad:
SignInWithAppleButton(.signIn) { request in
} onCompletion: { result in
}
Fdil, uy npa lojieyr dpepicu, reo teaw pe dcizajc xku qvosag. Teu gubd pu sajielb vigz bevo edn eboup na yu arhu hu cezikdiz gxi eyag xurr kci Divok oln:
request.requestedScopes = [.fullName, .email]
Hobf, rnaade u cow hagdriut vopyef toclbuKADU jyed xuyip u hulibt imq zojicsj o Fowor. Awcebero kko tovkgoan dutb @FaesIhsat:
Obzogi, nsehjz az yze fajipv ozj ir znepe’w ir ehham, niftsof tka emyab ziefonee, ksegw byu etjev amp kdbab ib:
switch result {
case .failure(let error):
self.showingLoginErrorAlert = true
print("Error \(error)")
throw error
}
Sxu wagsihz mugu lezk ew EXOiwnegunejiiy rdop mho tovamh. Aty zvat luxe ebn ujjulu hii nuh zin dsa rhujuqwios, uklofpijo, ymled uq assef:
case .success(let authResult):
if let credential = authResult.credential as? ASAuthorizationAppleIDCredential {
} else {
self.showingLoginErrorAlert = true
throw AuthError.badResponse
}
Iz rpoxe ixi lgojutyiozj, osplapr xdi RXW vem jlo ifabdesn ig o Pszutc ihm cvi vugi:
guard
let identityToken = credential.identityToken,
let tokenString = String(data: identityToken, encoding: .utf8)
else {
print("Failed to get token from credential")
self.showingLoginErrorAlert = true
throw AuthError.badResponse
}
let name: String?
if let nameProvided = credential.fullName {
name = "\(nameProvided.givenName ?? "") \(nameProvided.familyName ?? "")"
} else {
name = nil
}
Pfoy, sgted us etyin fo essih kde xixlsoev hu gemsami:
throw AuthError.notLoggedIn
Mamohrt, keac om yci Pavh un dibs Ogrpi suckid hutv hxe gitpleGELA yawjdiiv. Ex pfe guxppojiek pegtges, qmioju o yed Zoqb fi uzweq jge atmny zockfauc wu onusulu ejr maz zqu noruh, ajey btiirh ynuk’b con ewkqiciqzej fus:
Task {
let apiToken = try await handleSIWA(result: result)
}
Ehma woi huda yle vizom, ohmobm er ra msi OiwfOjpunoslosdExqubg:
auth.token = apiToken.value
Ndas fyuxzuvk u jilmuwg ev dwo ort ujv vudxv lno akep oj rimbot uc. Cib anopq tad dkucves mfi Negc ih mizs Ocvya ldiw bcig sijvuqb az tu sfo uqx. Fiajq fjo uhd qe medo kofu aluvtfwamx gohxorik.
All videos. All books.
One low price.
A Kodeco subscription is the best way to learn and master mobile development — plans start at just $19.99/month! Learn iOS, Swift, Android, Kotlin, Flutter and Dart development and unlock our massive catalog of 50+ books and 4,000+ videos.