Search code examples
iosflutterautofill

Show Automatic Strong password iOS in Flutter app


For a small coding project I manually installed my homemade Flutter app on my iPhone. This app has a Registration page, where a user can fill in their email and password to sign up for the app. To enable iOS Automatic Strong Password I used the Flutter AutofillGroup widget, and provided the appropriate AutofillHints to the corresponding textfields:

return AuthScaffoldView(
      title: 'Sign in',
      child: Container(
        color: Colors.white,
        child: AutofillGroup(
          child: Column(
            children: [
              CupertinoTextField(
                onEditingComplete: () => FocusScope.of(context).unfocus(),
                placeholder: 'Email',
                keyboardType: TextInputType.emailAddress,
                controller: model.editableUser.email,
                autofillHints: [AutofillHints.email],
                clearButtonMode: OverlayVisibilityMode.editing,
              ),
              CupertinoTextField(
                onEditingComplete: () => FocusScope.of(context).unfocus(),
                placeholder: 'Wachtwoord',
                controller: model.editableUser.password,
                autofillHints: [AutofillHints.newPassword],
                clearButtonMode: OverlayVisibilityMode.editing,
              ),
              CupertinoTextField(...

When I run the app on my phone, the AutofillHints work as expected for the email TextField, but on tapping the password TextField I get the following error as Xcode output:

[AutoFill] Cannot show Automatic Strong Passwords for app bundleID: {bundleID} due to error: Cannot identify the calling app's process. Check teamID and bundleID in your app's application-identifier entitlement.

I signed my app in Xcode (under Signing & Capabilities) with the appropriate Team and Bundle Identifier. Does anybody know where this error is coming from?


Solution

  • I was able to solve this by meeting the following prerequisites for Autofill Strong Password to work on iOS:

    1. Set up Associated Domains: https://developer.apple.com/documentation/xcode/supporting-associated-domains. It involves serving an apple-app-site-association file from the root (or .well-known) directory of your webserver, and adding the Associated Domains entitlement to your list of app entitlements.
    2. Add the Autofill Credential Provider entitlement to your app.

    PS. The latest Flutter 2.8.x contains a bug, which is discussed here https://github.com/flutter/flutter/issues/94043, so if you want to get it working you need to either downgrade to v.2.5.x or wait for the bug fix.

    EDIT: With Flutter 2.10.1 the abovementioned bug is fixed.