diff --git a/src/iOS.Autofill/CredentialProviderViewController.cs b/src/iOS.Autofill/CredentialProviderViewController.cs index 82400ef03..8caa4f79b 100644 --- a/src/iOS.Autofill/CredentialProviderViewController.cs +++ b/src/iOS.Autofill/CredentialProviderViewController.cs @@ -203,12 +203,18 @@ namespace Bit.iOS.Autofill private async Task ProvideCredentialAsync() { var cipherService = ServiceContainer.Resolve("cipherService", true); - var cipher = await cipherService?.GetAsync(_context.CredentialIdentity.RecordIdentifier); - if (cipher == null || cipher.Type != Bit.Core.Enums.CipherType.Login) + Bit.Core.Models.Domain.Cipher cipher = null; + var cancel = cipherService == null || _context.CredentialIdentity?.RecordIdentifier == null; + if (!cancel) + { + cipher = await cipherService.GetAsync(_context.CredentialIdentity.RecordIdentifier); + cancel = cipher == null || cipher.Type != Bit.Core.Enums.CipherType.Login || cipher.Login == null; + } + if (cancel) { var err = new NSError(new NSString("ASExtensionErrorDomain"), Convert.ToInt32(ASExtensionErrorCode.CredentialIdentityNotFound), null); - ExtensionContext.CancelRequest(err); + ExtensionContext?.CancelRequest(err); return; }