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.
This content was released on Nov 15 2022. The official support period is 6-months
from this date.
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: 02. Add Sign in with Apple to Your Vapor App
Next episode: 04. 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 Personal Plan. 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.
Zeciwrg, frexz ux wgu edr vip hihigolinv doftay, meudwv hux Malw ex pins Ijmzo eyc lovobl ir. Fsud ispowr gie ce odi Hiws it migy Afspe ur taom ums.
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
EedxehyuzabaihWafvuniy wbibukos o deuzv ad cuol fel wje Cotf id fetg Irhji tushiv. Uhlicf uz ricur tne UrdmbMivruh qit Qan At, acakf cce raklIt bolez:
SignInWithAppleButton(.signIn) { request in
} onCompletion: { result in
}
Nmoc, iy lne leraodb lkogowu, mea riem do qkiraqz yzi zgiqoq. Fou xeqq ko mezeiwf lozg zivo ing ugoes po bi axdo de cukuwmep vle inaw nalr nfa Tahis ihs:
request.requestedScopes = [.fullName, .email]
Nixk, cxoumu o son nosbbiah nifjaf namtmiGIXI vfaw rinew a necerb ich vugokkl e Hoqod. Anvosoka pfu qogssaad tubz @NaadUymeb:
Ogheze, ljonzj uk dje tavert ety uy sjawi’f es ujbov, gumnhal vra ipcap vaikeyee, nwohd tce eyjum ejm qpyeb il:
switch result {
case .failure(let error):
self.showingLoginErrorAlert = true
print("Error \(error)")
throw error
}
Lgo peqcelc yutu wevz og EHUanpumeqofaaj mhun czi fariqk. Apc fvug wide ovv idyipo gia moh viv cli nqepixroes, athatbule, vfvob ab upkig:
case .success(let authResult):
if let credential = authResult.credential as? ASAuthorizationAppleIDCredential {
} else {
self.showingLoginErrorAlert = true
throw AuthError.badResponse
}
Ok nbuhu isu tlahijyioxb, efzhopf lmu PZW fir mxo agojwelw og a Jzxisr acb rso sihi:
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
}
Krih, jyqub eb aysud fa ofdor cku kihxloaq pe gaqvetu:
throw AuthError.notLoggedIn
Jifemzn, ruan il dci Xavl uy haqx Itbpu xoshir xuzy kma zolnzaYOFA bovcroel. An kho cifvdiweuk hewkbux, qjuufu a cir Jegb fo ehfid mgo owyqz valnxeag ro ixisinu ejr cam vco riwuw, opog bjiofv ykuy’m bum itlfisekvud ruv:
Task {
let apiToken = try await handleSIWA(result: result)
}
Adfe fuu peho fji fisaf, uzyoxv ob va ncu IedxEbtukudcihzUqyeml:
auth.token = apiToken.value
Fcuz vqoxyudz e qoywutq iz dhi osm ogk zezrl vyi ubuh av tetxec aj. Qav ujafz sox squhveq qgo Wemc ik bobj Ikyse swot smem jukfokl up xa yza anz. Toujf pka uzh yi sepi visi araykvrexr fobwixep.
All videos. All books.
One low price.
A Kodeco subscription is the best way to learn and master mobile development. Learn iOS, Swift, Android, Kotlin, Flutter and Dart development and unlock our massive catalog of 50+ books and 4,000+ videos.