Skip to content

Commit 5d1263d

Browse files
committed
fixes
1 parent d598c37 commit 5d1263d

File tree

1 file changed

+23
-2
lines changed

1 file changed

+23
-2
lines changed

FirebaseAuth/Tests/SampleSwift/AuthenticationExample/ViewControllers/AuthViewController.swift

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1124,6 +1124,27 @@ extension AuthViewController: ASAuthorizationControllerDelegate,
11241124

11251125
func authorizationController(controller: ASAuthorizationController,
11261126
didCompleteWithAuthorization authorization: ASAuthorization) {
1127+
if #available(iOS 16.0, macOS 12.0, tvOS 16.0, *),
1128+
let regCred = authorization.credential
1129+
as? ASAuthorizationPlatformPublicKeyCredentialRegistration {
1130+
Task { @MainActor [weak self] in
1131+
guard let self else { return }
1132+
do {
1133+
guard let user = AppManager.shared.auth().currentUser else {
1134+
self.showAlert(for: "Finalize failed", message: "No signed-in user.")
1135+
return
1136+
}
1137+
_ = try await user.finalizePasskeyEnrollment(withPlatformCredential: regCred)
1138+
self.showAlert(for: "Passkey Enrollment", message: "Succeeded")
1139+
print("Passkey Enrollment succeeded.")
1140+
} catch {
1141+
self.showAlert(for: "Passkey Enrollment failed", message: error.localizedDescription)
1142+
print("Finalize enrollment failed: \(error.localizedDescription)")
1143+
}
1144+
}
1145+
return
1146+
}
1147+
11271148
guard let appleIDCredential = authorization.credential as? ASAuthorizationAppleIDCredential
11281149
else {
11291150
print("Unable to retrieve AppleIDCredential")
@@ -1171,10 +1192,10 @@ extension AuthViewController: ASAuthorizationControllerDelegate,
11711192

11721193
func authorizationController(controller: ASAuthorizationController,
11731194
didCompleteWithError error: any Error) {
1174-
// Ensure that you have:
1195+
print("ASAuthorization failed: \(error)")
1196+
// for Sign In with Apple, ensure that you have:
11751197
// - enabled `Sign in with Apple` on the Firebase console
11761198
// - added the `Sign in with Apple` capability for this project
1177-
print("Sign in with Apple failed: \(error)")
11781199
}
11791200

11801201
// MARK: ASAuthorizationControllerPresentationContextProviding

0 commit comments

Comments
 (0)