Hi Is it possible to get textContentType
raw value in swift/swiftui without user having to tap on it when keyboard appears.
I want the value to get copied in the background state without getting user to click on it so it autofills textfields.
struct ContentView: View {
@State var code: String = ""
@State var pasteBoard = UIPasteboard.general
var body: some View {
VStack {
TextField("Code", text: $code)
.textContentType(.oneTimeCode)
.keyboardType(.numberPad)
.onChange(of: code) { newValue in
pasteBoard.string = newValue
}
.padding()
}
}
}
I am using pasteboard to copy any newly inserted value into the textfield.
Like in the image below I am using .textContentType(.oneTimeCode)
to get an otp code from an sms message, I want this to however be send to the textfield without user interaction, is that possible?