Skip to content

Commit 781420a

Browse files
Add UI to test if device is attached
1 parent 46ede5d commit 781420a

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

LibFido2TestApp/ContentView.swift

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ struct ContentView: View {
1616
@AppStorage("origin") var origin = ""
1717
@AppStorage("devicePin") var devicePin = ""
1818
@State var responseJson = ""
19+
@State private var isDevicePresent = false
20+
@State private var isDevicePresentAlertShown = false
1921
var body: some View {
2022
VStack {
2123
VStack {
@@ -33,6 +35,17 @@ struct ContentView: View {
3335
}
3436
}
3537
}
38+
Button("Is Device Present?") {
39+
isDevicePresent = fido2.hasDeviceAttached()
40+
isDevicePresentAlertShown = true
41+
}
42+
.alert(isPresented: $isDevicePresentAlertShown) {
43+
Alert(
44+
title: Text("Device is \(isDevicePresent ? "present" : "not present")"),
45+
message: nil,
46+
dismissButton: .default(Text("OK"))
47+
)
48+
}
3649
Button("Cancel") {
3750
fido2.cancel()
3851
}

0 commit comments

Comments
 (0)