Skip to content

Commit

Permalink
Merge pull request #95 from niscy-eudiw/fixes
Browse files Browse the repository at this point in the history
execute FaceID authenticated action in main actor
  • Loading branch information
phisakel authored Aug 27, 2024
2 parents d8a7416 + 1997f28 commit d2c511d
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions Sources/EudiWalletKit/EudiWallet.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import OpenID4VCI
import SwiftCBOR
import Logging
import FileLogging
import UIKit

/// User wallet implementation
public final class EudiWallet: ObservableObject {
Expand Down Expand Up @@ -369,6 +370,7 @@ public final class EudiWallet: ObservableObject {
/// - isFallBack: true if fallback (ask for pin code)
/// - dismiss: action to dismiss current page
/// - action: action to perform after authentication
@MainActor
static func authorizedAction<T>(isFallBack: Bool = false, action: () async throws -> T, disabled: Bool, dismiss: () -> Void, localizedReason: String) async throws -> T? {
guard !disabled else {
return try await action()
Expand All @@ -380,6 +382,10 @@ public final class EudiWallet: ObservableObject {
do {
let success = try await context.evaluatePolicy(policy, localizedReason: localizedReason)
if success {
if !UIApplication.shared.connectedScenes.allSatisfy({ $0.activationState == .foregroundActive }) {
// Delay the task by 1 second if not foreground
try await Task.sleep(nanoseconds: 1_000_000_000)
}
return try await action()
}
else { dismiss()}
Expand Down

0 comments on commit d2c511d

Please sign in to comment.