mirror of
https://github.com/bitwarden/mobile
synced 2025-12-23 19:53:50 +00:00
PM-2732 Changed to Delegate approach for the new iOS 17 credential provider methods
This commit is contained in:
@@ -5,8 +5,30 @@ using ObjCRuntime;
|
||||
|
||||
namespace XamariniOS17CredentialProviderBinding
|
||||
{
|
||||
// @interface ASCredentialRequestCompat : NSObject
|
||||
[BaseType (typeof(NSObject))]
|
||||
interface IASCredentialProviderCompatDelegate { }
|
||||
|
||||
// @protocol ASCredentialProviderCompatDelegate
|
||||
[Protocol, Model(AutoGeneratedName = true)]
|
||||
interface ASCredentialProviderCompatDelegate
|
||||
{
|
||||
// @required -(void)prepareInterfaceToProvideCredentialCompatFor:(ASCredentialRequestCompat * _Nonnull)credentialRequest;
|
||||
[Abstract]
|
||||
[Export("prepareInterfaceToProvideCredentialCompatFor:")]
|
||||
void PrepareInterfaceToProvideCredentialCompatFor(ASCredentialRequestCompat credentialRequest);
|
||||
|
||||
// @required -(void)provideCredentialWithoutUserInteractionCompatFor:(ASCredentialRequestCompat * _Nonnull)credentialRequest;
|
||||
[Abstract]
|
||||
[Export("provideCredentialWithoutUserInteractionCompatFor:")]
|
||||
void ProvideCredentialWithoutUserInteractionCompatFor(ASCredentialRequestCompat credentialRequest);
|
||||
|
||||
// @required -(void)prepareInterfaceCompatForPasskeyRegistration:(ASCredentialRequestCompat * _Nonnull)registrationRequest;
|
||||
[Abstract]
|
||||
[Export("prepareInterfaceCompatForPasskeyRegistration:")]
|
||||
void PrepareInterfaceCompatForPasskeyRegistration(ASCredentialRequestCompat registrationRequest);
|
||||
}
|
||||
|
||||
// @interface ASCredentialRequestCompat : NSObject
|
||||
[BaseType (typeof(NSObject))]
|
||||
[DisableDefaultCtor]
|
||||
interface ASCredentialRequestCompat
|
||||
{
|
||||
@@ -62,35 +84,38 @@ namespace XamariniOS17CredentialProviderBinding
|
||||
[BaseType (typeof(ASCredentialProviderViewController))]
|
||||
interface BaseASCredentialProviderViewController
|
||||
{
|
||||
// -(void)prepareInterfaceToProvideCredentialForRequest:(id<ASCredentialRequest> _Nonnull)credentialRequest;
|
||||
//[Export ("prepareInterfaceToProvideCredentialForRequest:")]
|
||||
//void PrepareInterfaceToProvideCredentialForRequest (ASCredentialRequest credentialRequest);
|
||||
// -(void)prepareInterfaceToProvideCredentialForRequest:(id<ASCredentialRequest> _Nonnull)credentialRequest;
|
||||
//[Export ("prepareInterfaceToProvideCredentialForRequest:")]
|
||||
//void PrepareInterfaceToProvideCredentialForRequest (ASCredentialRequest credentialRequest);
|
||||
|
||||
//// -(void)provideCredentialWithoutUserInteractionForRequest:(id<ASCredentialRequest> _Nonnull)credentialRequest;
|
||||
//[Export ("provideCredentialWithoutUserInteractionForRequest:")]
|
||||
//void ProvideCredentialWithoutUserInteractionForRequest (ASCredentialRequest credentialRequest);
|
||||
//// -(void)provideCredentialWithoutUserInteractionForRequest:(id<ASCredentialRequest> _Nonnull)credentialRequest;
|
||||
//[Export ("provideCredentialWithoutUserInteractionForRequest:")]
|
||||
//void ProvideCredentialWithoutUserInteractionForRequest (ASCredentialRequest credentialRequest);
|
||||
|
||||
//// -(void)prepareInterfaceForPasskeyRegistration:(id<ASCredentialRequest> _Nonnull)registrationRequest;
|
||||
//[Export ("prepareInterfaceForPasskeyRegistration:")]
|
||||
//void PrepareInterfaceForPasskeyRegistration (ASCredentialRequest registrationRequest);
|
||||
//// -(void)prepareInterfaceForPasskeyRegistration:(id<ASCredentialRequest> _Nonnull)registrationRequest;
|
||||
//[Export ("prepareInterfaceForPasskeyRegistration:")]
|
||||
//void PrepareInterfaceForPasskeyRegistration (ASCredentialRequest registrationRequest);
|
||||
|
||||
// -(void)prepareInterfaceToProvideCredentialCompatFor:(ASCredentialRequestCompat * _Nonnull)credentialRequest;
|
||||
[Export ("prepareInterfaceToProvideCredentialCompatFor:")]
|
||||
[Abstract]
|
||||
void PrepareInterfaceToProvideCredentialCompatFor (ASCredentialRequestCompat credentialRequest);
|
||||
// -(void)prepareInterfaceToProvideCredentialCompatFor:(ASCredentialRequestCompat * _Nonnull)credentialRequest;
|
||||
//[Export ("prepareInterfaceToProvideCredentialCompatFor:")]
|
||||
// [Abstract]
|
||||
// void PrepareInterfaceToProvideCredentialCompatFor (ASCredentialRequestCompat credentialRequest);
|
||||
|
||||
// -(void)provideCredentialWithoutUserInteractionCompatFor:(ASCredentialRequestCompat * _Nonnull)credentialRequest;
|
||||
[Export ("provideCredentialWithoutUserInteractionCompatFor:")]
|
||||
[Abstract]
|
||||
void ProvideCredentialWithoutUserInteractionCompatFor (ASCredentialRequestCompat credentialRequest);
|
||||
//// -(void)provideCredentialWithoutUserInteractionCompatFor:(ASCredentialRequestCompat * _Nonnull)credentialRequest;
|
||||
//[Export ("provideCredentialWithoutUserInteractionCompatFor:")]
|
||||
// [Abstract]
|
||||
// void ProvideCredentialWithoutUserInteractionCompatFor (ASCredentialRequestCompat credentialRequest);
|
||||
|
||||
// -(void)prepareInterfaceCompatForPasskeyRegistration:(ASCredentialRequestCompat * _Nonnull)registrationRequest;
|
||||
[Export ("prepareInterfaceCompatForPasskeyRegistration:")]
|
||||
[Abstract]
|
||||
void PrepareInterfaceCompatForPasskeyRegistration (ASCredentialRequestCompat registrationRequest);
|
||||
//// -(void)prepareInterfaceCompatForPasskeyRegistration:(ASCredentialRequestCompat * _Nonnull)registrationRequest;
|
||||
//[Export ("prepareInterfaceCompatForPasskeyRegistration:")]
|
||||
// [Abstract]
|
||||
// void PrepareInterfaceCompatForPasskeyRegistration (ASCredentialRequestCompat registrationRequest);
|
||||
|
||||
// -(instancetype _Nonnull)initWithNibName:(NSString * _Nullable)nibNameOrNil bundle:(NSBundle * _Nullable)nibBundleOrNil __attribute__((objc_designated_initializer));
|
||||
[Export ("initWithNibName:bundle:")]
|
||||
[Export("SetCompatDelegate:")]
|
||||
void SetCompatDelegate(IASCredentialProviderCompatDelegate @delegate);
|
||||
|
||||
// -(instancetype _Nonnull)initWithNibName:(NSString * _Nullable)nibNameOrNil bundle:(NSBundle * _Nullable)nibBundleOrNil __attribute__((objc_designated_initializer));
|
||||
[Export ("initWithNibName:bundle:")]
|
||||
[DesignatedInitializer]
|
||||
IntPtr Constructor ([NullAllowed] string nibNameOrNil, [NullAllowed] NSBundle nibBundleOrNil);
|
||||
|
||||
|
||||
@@ -115,29 +115,34 @@ open class BaseASCredentialProviderViewController : ASCredentialProviderViewCont
|
||||
// MARK: iOS 17 new methods
|
||||
|
||||
override final public func prepareInterfaceToProvideCredential(for credentialRequest: ASCredentialRequest) {
|
||||
prepareInterfaceToProvideCredentialCompat(for: convertRequestToCompat(from: credentialRequest))
|
||||
guard let compatDelegate = compatDelegate else {
|
||||
return
|
||||
}
|
||||
compatDelegate.prepareInterfaceToProvideCredentialCompat(for: convertRequestToCompat(from: credentialRequest))
|
||||
}
|
||||
|
||||
override final public func provideCredentialWithoutUserInteraction(for credentialRequest: ASCredentialRequest) {
|
||||
provideCredentialWithoutUserInteractionCompat(for: convertRequestToCompat(from: credentialRequest))
|
||||
guard let compatDelegate = compatDelegate else {
|
||||
return
|
||||
}
|
||||
compatDelegate.provideCredentialWithoutUserInteractionCompat(for: convertRequestToCompat(from: credentialRequest))
|
||||
}
|
||||
|
||||
override final public func prepareInterface(forPasskeyRegistration registrationRequest: ASCredentialRequest) {
|
||||
prepareInterfaceCompat(forPasskeyRegistration: convertRequestToCompat(from: registrationRequest))
|
||||
guard let compatDelegate = compatDelegate else {
|
||||
return
|
||||
}
|
||||
compatDelegate.prepareInterfaceCompat(forPasskeyRegistration: convertRequestToCompat(from: registrationRequest))
|
||||
}
|
||||
|
||||
// MARK: Compat methods
|
||||
// MARK: Compat
|
||||
|
||||
var compatDelegate: ASCredentialProviderCompatDelegate? = nil;
|
||||
|
||||
@objc
|
||||
open func prepareInterfaceToProvideCredentialCompat(for credentialRequest: ASCredentialRequestCompat){
|
||||
}
|
||||
|
||||
@objc
|
||||
open func provideCredentialWithoutUserInteractionCompat(for credentialRequest: ASCredentialRequestCompat) {
|
||||
}
|
||||
|
||||
@objc
|
||||
open func prepareInterfaceCompat(forPasskeyRegistration registrationRequest: ASCredentialRequestCompat) {
|
||||
public func SetCompatDelegate(_ delegate: ASCredentialProviderCompatDelegate)
|
||||
{
|
||||
compatDelegate = delegate
|
||||
}
|
||||
|
||||
func convertRequestToCompat(from credentialRequest: ASCredentialRequest) -> ASCredentialRequestCompat {
|
||||
@@ -146,3 +151,16 @@ open class BaseASCredentialProviderViewController : ASCredentialProviderViewCont
|
||||
credentialIdentity: credentialRequest.credentialIdentity)
|
||||
}
|
||||
}
|
||||
|
||||
@objc(ASCredentialProviderCompatDelegate)
|
||||
public protocol ASCredentialProviderCompatDelegate
|
||||
{
|
||||
@objc
|
||||
func prepareInterfaceToProvideCredentialCompat(for credentialRequest: ASCredentialRequestCompat)
|
||||
|
||||
@objc
|
||||
func provideCredentialWithoutUserInteractionCompat(for credentialRequest: ASCredentialRequestCompat)
|
||||
|
||||
@objc
|
||||
func prepareInterfaceCompat(forPasskeyRegistration registrationRequest: ASCredentialRequestCompat)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user