@@ -1124,6 +1124,27 @@ extension AuthViewController: ASAuthorizationControllerDelegate,
1124
1124
1125
1125
func authorizationController( controller: ASAuthorizationController ,
1126
1126
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
+
1127
1148
guard let appleIDCredential = authorization. credential as? ASAuthorizationAppleIDCredential
1128
1149
else {
1129
1150
print ( " Unable to retrieve AppleIDCredential " )
@@ -1171,10 +1192,10 @@ extension AuthViewController: ASAuthorizationControllerDelegate,
1171
1192
1172
1193
func authorizationController( controller: ASAuthorizationController ,
1173
1194
didCompleteWithError error: any Error ) {
1174
- // Ensure that you have:
1195
+ print ( " ASAuthorization failed: \( error) " )
1196
+ // for Sign In with Apple, ensure that you have:
1175
1197
// - enabled `Sign in with Apple` on the Firebase console
1176
1198
// - added the `Sign in with Apple` capability for this project
1177
- print ( " Sign in with Apple failed: \( error) " )
1178
1199
}
1179
1200
1180
1201
// MARK: ASAuthorizationControllerPresentationContextProviding
0 commit comments