Accessible input fields
On iOS, ensure that the UITextField elements used for authentication can be identified by password managers. This means you need to set an appropriate UITextContentType, such as .username and .password.
Password managers typically recognize authentication fields based on these properties and can automatically fill in the credentials of the user.
swift
class LoginViewController: UIViewController {
@IBOutlet weak var usernameTextField: UITextField!
@IBOutlet weak var passwordTextField: UITextField!
override func viewDidLoad() {
super.viewDidLoad()
// Setup appropriate textContentType for input fields.
usernameTextField.textContentType = .username
passwordTextField.textContentType = .password
}
} json
{
"applinks": {
"details": [
{
"appID": "TEAM_ID.com.example.bundle",
"paths": ["/auth/*"]
}
]
}
} swift
class AppDelegate: UIResponder, UIApplicationDelegate {
func application(
_ application: UIApplication,
continue userActivity: NSUserActivity,
restorationHandler: @escaping ([UIUserActivityRestoring]?) -> Void
) -> Bool {
if let url = userActivity.webpageURL {
// Authenticate based on parameters of incoming URL
}
}
} In SwiftUI, ensure that the TextField elements used for authentication can be identified by password managers. This means you need to apply an appropriate textContentType-ufdv) modifier, such as .username and .password.
Password managers typically recognize authentication fields based on these properties and can automatically fill in the credentials of the user.
swift
struct LoginView: View {
@State private var username: String = ""
@State private var password: String = ""
var body: some View {
VStack {
// Username TextField
TextField("Username", text: $username)
.textContentType(.username) // Identify as username
.autocapitalization(.none)
// Password TextField
SecureField("Password", text: $password)
.textContentType(.password) // Identify as password
.padding()
}
}
} json
{
"applinks": {
"details": [
{
"appID": "TEAM_ID.com.example.bundle",
"paths": ["/auth/*"]
}
]
}
} swift
@main
struct ApptApp: App {
var body: some Scene {
WindowGroup {
ContentView()
.onOpenURL { url in
// Authenticate based on parameters of incoming URL
}
}
}
}