One Time Codes

How can I trigger, or rather, when is the ASCredentialProviderViewController.prepareOneTimeCodeCredentialList(for:) method triggered? I can't seem to get it to work.

  1. I've added the ProvidesOneTimeCodes key to the Info.plist.
  2. I've added the com.apple.developer.authentication-services.autofill-credential-provider entitlement.
  3. Example of the extension:
    class CredentialProviderViewController: ASCredentialProviderViewController {
        override func prepareOneTimeCodeCredentialList(for serviceIdentifiers: [ASCredentialServiceIdentifier]) {
            print("********************************* prepareOneTimeCodeCredentialList \(serviceIdentifiers)")
        }
        
        override func prepareInterfaceForUserChoosingTextToInsert() {
            print("********************************* prepareInterfaceForUserChoosingTextToInsert")
        }
    }
    
  4. The app is enabled in the AUTOFILL FROM: in Settings App.

On iOS, ASCredentialProviderViewController.prepareOneTimeCodeCredentialList(for:) is called from Safari when a user focuses a one time code field and taps the key icon in the QuickType bar to see more suggestions.

If you do this and still don't see your method being called, please file a Feedback with a sysdiagnose and we will be happy to investigate further.

The problem is that the "Key" icon in the QuickType bar is not appearing.

UPDATE: To make the system show the "Key," you need to feed the ASCredentialIdentityStore with ASOneTimeCodeCredentialIdentity using a serviceIdentifier that matches the domain or URL. To be honest, this is not ideal. Now, we need to have a domain or URL to be able to show the autofill. However, according to the Key-Uri-Format, we don't have a domain or URL when setting up 2FA.

One Time Codes
 
 
Q