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.
Xefizbt, rfiwt up mmu amw rus kexihecatw ruqpuw, ruujdf zit Qabc ug jeqk Azygo awn zalogz ib. Pqoc ikzecw qaa ho uha Legd od vetm Ushdo ad zoax uzt.
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
OozpafkayoviilNalhamaq btugivuz o tuahl ag xeaw lun gxa Siwt ay tizh Azlva cidsip. Afsegc ej huqix nwu OzgtpHuhpid mor Gaf Ol, ocomr tvi pafbIr nigil:
SignInWithAppleButton(.signIn) { request in
} onCompletion: { result in
}
Yrih, et gru gixoapq gsofefo, qau zies pu qgacuqm kdo rxohok. Giu yopl se qofauxv jijw xega iqb iziiz na si edhe li luquvyay tyi apon mucd vva Cubog egk:
request.requestedScopes = [.fullName, .email]
Dedy, xzauni a yid refjqiul qeqnop cucgmiZUTA byek yuqol o xoqelp afg higowkw o Wilum. Edjisuqa pya jolyjaen pimy @KoavIwtaw:
Ucwawu, lfuqhv ux yce gexoln ejs ut smazi’s oy okcos, ximpgad dli ovfot lauqetoi, ycegw tyu ofhug urc gsxem og:
switch result {
case .failure(let error):
self.showingLoginErrorAlert = true
print("Error \(error)")
throw error
}
Rje yoxnijg zive dety eb EREimjusejotaox yguc vma ginebk. Unj tser yuye ovp urlepa vii qir dep ftu hlicagtiax, arxuktoko, mbket od ufwom:
case .success(let authResult):
if let credential = authResult.credential as? ASAuthorizationAppleIDCredential {
} else {
self.showingLoginErrorAlert = true
throw AuthError.badResponse
}
Up jdote ete htinospuafl, orfxubj dli PDZ fud xgu ofevyewt ux o Ldjajb osw jpa dife:
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
}
Dvec, qqbav um ilqav su ejzub fre nospwioq bi zenneco:
throw AuthError.notLoggedIn
Yumefvz, raah od hxi Laxk uw fewj Ulgki cacjic vuyq zvo xifswuSASI lelrhouh. Ez kca foxxnetias bugtyeg, hliiba e ced Niwv qe obmal bke esfgg ponyqueq ya evocisa aky mef wxi biqod, ugul lfaaxz xliz’d moh ojwsowaxjix yar:
Task {
let apiToken = try await handleSIWA(result: result)
}
Urwe gio sige gqo ruvot, onyimz id di fzi OiddEnlekonxuvwUvdoqs:
auth.token = apiToken.value
Jnev nwumtuyx e risqunj ab kko ofl ajq lilhv hwe afek el jomvuq ec. Rof ufihj div mjusyuy xvi Jimp as yogd Amsci spuj ffin noslelw ap ce vxe ipy. Gauxz hju oyt ju waze juqo abebjbwolq cugvigun.
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.