InitAppIfNeeded

This commit is contained in:
Kyle Spearrin 2019-07-22 08:22:02 -04:00
parent 13ddd10c40
commit 9164c9b946

View file

@ -34,6 +34,7 @@ namespace Bit.iOS.Autofill
public override void PrepareCredentialList(ASCredentialServiceIdentifier[] serviceIdentifiers) public override void PrepareCredentialList(ASCredentialServiceIdentifier[] serviceIdentifiers)
{ {
InitAppIfNeeded();
_context.ServiceIdentifiers = serviceIdentifiers; _context.ServiceIdentifiers = serviceIdentifiers;
if(serviceIdentifiers.Length > 0) if(serviceIdentifiers.Length > 0)
{ {
@ -67,6 +68,7 @@ namespace Bit.iOS.Autofill
public override void ProvideCredentialWithoutUserInteraction(ASPasswordCredentialIdentity credentialIdentity) public override void ProvideCredentialWithoutUserInteraction(ASPasswordCredentialIdentity credentialIdentity)
{ {
InitAppIfNeeded();
if(!IsAuthed() || IsLocked()) if(!IsAuthed() || IsLocked())
{ {
var err = new NSError(new NSString("ASExtensionErrorDomain"), var err = new NSError(new NSString("ASExtensionErrorDomain"),
@ -80,6 +82,7 @@ namespace Bit.iOS.Autofill
public override void PrepareInterfaceToProvideCredential(ASPasswordCredentialIdentity credentialIdentity) public override void PrepareInterfaceToProvideCredential(ASPasswordCredentialIdentity credentialIdentity)
{ {
InitAppIfNeeded();
if(!CheckAuthed()) if(!CheckAuthed())
{ {
return; return;
@ -90,6 +93,7 @@ namespace Bit.iOS.Autofill
public override void PrepareInterfaceForExtensionConfiguration() public override void PrepareInterfaceForExtensionConfiguration()
{ {
InitAppIfNeeded();
_context.Configuring = true; _context.Configuring = true;
if(!CheckAuthed()) if(!CheckAuthed())
{ {
@ -260,5 +264,13 @@ namespace Bit.iOS.Autofill
iOSCoreHelpers.Bootstrap(); iOSCoreHelpers.Bootstrap();
iOSCoreHelpers.AppearanceAdjustments(); iOSCoreHelpers.AppearanceAdjustments();
} }
private void InitAppIfNeeded()
{
if(ServiceContainer.RegisteredServices == null || ServiceContainer.RegisteredServices.Count == 0)
{
InitApp();
}
}
} }
} }