import SwiftUI
import MetaMapSDK
import UIKit
struct ContentView: View {
var body: some View {
VStack {
ZStack {
//MARK: MetaMapDelegateObserver
MetaMapDelegateObserver { identityId, verificationId in
print("\(identityId), \(verificationId)")
} cancelled: {
print("cancelled")
}
HStack {
Button(action: {
MetaMap.shared.showMetaMapFlow(clientId: "YOUR_CLIENT_ID", flowId: "YOUR_FLOW_ID", metadata: ["key1": "value1", "key2": 123])
}) {
Text("press me")
}
}
}
}
}
}
struct MetaMapDelegateObserver: UIViewControllerRepresentable {
let vc = MatiViewController()
public func makeUIViewController(context: Context) -> MatiViewController {
return vc
}
public func updateUIViewController(_ uiViewController: MatiViewController, context: Context) {}
var success: (_ identityId: String?, _ verificationId: String?) -> Void
var cancelled: () -> Void
public func makeCoordinator() -> Coordinator {
Coordinator(success: success, cancelled: cancelled)
}
public class Coordinator: NSObject, MetaMapButtonResultDelegate {
public func verificationSuccess(identityId: String?, verificationID: String?) {
success(identityId, verificationID)
}
public func verificationCancelled() {
cancelled()
}
var success: (_ identityId: String?, _ verificationId: String?) -> Void
var cancelled: () -> Void
init(success: @escaping (_ identityId: String?, _ verificationId: String?) -> Void, cancelled: @escaping () -> Void) {
self.success = success
self.cancelled = cancelled
super.init()
MetaMapButtonResult.shared.delegate = self
}
}
}
class MetaMapViewController: UIViewController {}