-
Notifications
You must be signed in to change notification settings - Fork 36
Closed
Labels
pending-maintainer-responseIssue is pending response from an Amplify team memberIssue is pending response from an Amplify team memberquestionFurther information is requestedFurther information is requested
Description
Describe the bug
When executing the liveness feature in AWS Amplify, the process fails with an "An unknown error occurred" message. This occurs consistently and prevents further execution of the feature. There is no detailed error information provided in the logs, making it challenging to identify the root cause.
Steps To Reproduce
This is my code:
//App delegate
import UIKit
import Flutter
import Amplify
import AWSCognitoAuthPlugin
@main
@objc class AppDelegate: FlutterAppDelegate {
override func application(
_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
) -> Bool {
// Flutter Method Channel Setup
let controller: FlutterViewController = window?.rootViewController as! FlutterViewController
let methodChannel = FlutterMethodChannel(name: "LIVE_VERIFICATION_CHANNEL", binaryMessenger: controller.binaryMessenger)
methodChannel.setMethodCallHandler { [weak self] (call, result) in
if call.method == "startLiveVerification" {
guard let args = call.arguments as? [String: Any],
let sessionId = args["sessionId"] as? String else {
result(FlutterError(code: "INVALID_ARGUMENT", message: "Invalid session Id", details: nil))
return
}
print("session id is \(sessionId)")
let faceLivenessController = FaceLiveDetectionController()
faceLivenessController.sessionId = sessionId
faceLivenessController.flutterResult = result
faceLivenessController.modalPresentationStyle = .fullScreen
controller.present(faceLivenessController, animated: true, completion: nil)
} else {
result(FlutterMethodNotImplemented)
}
}
// Notification Center (if needed)
if #available(iOS 10.0, *) {
UNUserNotificationCenter.current().delegate = self as UNUserNotificationCenterDelegate
}
// Register generated plugins
GeneratedPluginRegistrant.register(with: self)
return super.application(application, didFinishLaunchingWithOptions: launchOptions)
}
}
// Liveness controller
import FaceLiveness
import Foundation
import SwiftUI
import UIKit
class FaceLiveDetectionController: UIViewController {
var sessionId: String?
var flutterResult: FlutterResult!
var hostingController: UIHostingController<FaceLivenessDetectorView>?
override func viewDidLoad() {
super.viewDidLoad()
configureFaceDetection()
}
private func configureFaceDetection() {
if let sessionID = self.sessionId {
let faceView = FaceLivenessDetectorView(
sessionID: "<SESSION_ID>",
credentialsProvider: MyCredentialsProvider(),
region: "<REGION>",
isPresented: .constant(true),
onCompletion: { result in
DispatchQueue.main.async {
switch result {
case .success:
self.callback("success")
case .failure(let error):
self.callback(error.message)
}
}
})
hostingController = createHostingController(with: faceView)
addHostingControllerAsChild(hostingController!)
configureConstraints(for: hostingController!.view)
}
}
private func callback(_ res: String) {
hostingController?.dismiss(animated: true, completion: nil)
if res == "success" {
flutterResult("success")
} else {
flutterResult(FlutterError(code: "error", message: res, details: nil))
}
}
private func createHostingController(with rootView: FaceLivenessDetectorView)
-> UIHostingController<FaceLivenessDetectorView>
{
return UIHostingController(rootView: rootView)
}
private func addHostingControllerAsChild(
_ hostingController: UIHostingController<FaceLivenessDetectorView>
) {
addChild(hostingController)
view.addSubview(hostingController.view)
}
private func configureConstraints(for view: UIView) {
view.translatesAutoresizingMaskIntoConstraints = false
NSLayoutConstraint.activate([
view.topAnchor.constraint(equalTo: self.view.topAnchor, constant: 10),
view.bottomAnchor.constraint(equalTo: self.view.bottomAnchor),
view.leadingAnchor.constraint(equalTo: self.view.leadingAnchor),
view.trailingAnchor.constraint(equalTo: self.view.trailingAnchor),
])
}
}
//My credentials Provider
import AWSPluginsCore
import Amplify
struct MyTemporaryCredentials: AWSTemporaryCredentials {
let accessKeyId: String
let secretAccessKey: String
let sessionToken: String
let expiration: Date
}
struct MyCredentialsProvider: AWSCredentialsProvider {
func fetchAWSCredentials() async throws -> AWSCredentials {
// Aquí simulas la obtención de credenciales
return MyTemporaryCredentials(
accessKeyId: "<ACCESS_KEY_HERE>",
secretAccessKey: "<SECRET_ACCESS_KEY>",
sessionToken: "",
expiration: Date().addingTimeInterval(100000) // 1 hora de validez
)
}
}
I started application and the camera was open, then when I started liveness check, camera finished and the logs register this:
Error creating the CFMessagePort needed to communicate with PPT.
Connection 1: received failure notification
flutter: Error in starting live verification: An unknown error occurred.
Expected behavior
Finish process successfuly.
Swift Liveness Version
2.42.1
Xcode version
16.2 (16C5032a)
Relevant log output
<details>
<summary>Log Messages</summary>
Error creating the CFMessagePort needed to communicate with PPT.
Connection 1: received failure notification
flutter: Error in starting live verification: An unknown error occurred.
</details>
Is this a regression?
No
Regression additional context
No response
OS Version
iOS 18.2 / MacOS 15.2
Device
IPhone 14
Specific to simulators
No response
Additional context
No response
Metadata
Metadata
Assignees
Labels
pending-maintainer-responseIssue is pending response from an Amplify team memberIssue is pending response from an Amplify team memberquestionFurther information is requestedFurther information is requested