How to check whether user has enabled/checked autofill credential provider extension or not from phone settings in iOS?

Viewed 186

I have implemented AutoFill Credential Provider Extension in iOS.
Everything is working fine but I am having one issue, not exactly an issue but I am unable to achieve the below functionality.

I want to get Autofill extension state every time when user open a specific viewController of my application.
So that I am able check whether it's enabled from settings or not.

If it is not enabled I will navigate user to phone settings otherwise user can use the app.

1 Answers

As documented we need to use ASCredentialIdentityStore state for that purpose:

demo

so you can add somewhere the following wrapped async call and use it to validate of extension is enabled:

- (void)checkExtesionEnabledWithCompletion:(void(^)(BOOL))completion {
    ASCredentialIdentityStore *store = [ASCredentialIdentityStore sharedStore];
    [store getCredentialIdentityStoreStateWithCompletion:^(ASCredentialIdentityStoreState * _Nonnull state) {
        completion(state.isEnabled);
    }];
}
Related