#[repr(C)]pub struct ASCredentialProviderViewController { /* private fields */ }
ASCredentialProviderViewController
only.Implementations§
Source§impl ASCredentialProviderViewController
impl ASCredentialProviderViewController
pub unsafe fn extensionContext( &self, ) -> Retained<ASCredentialProviderExtensionContext>
ASCredentialProviderExtensionContext
only.Sourcepub unsafe fn prepareCredentialListForServiceIdentifiers(
&self,
service_identifiers: &NSArray<ASCredentialServiceIdentifier>,
)
Available on macOS and crate feature ASCredentialServiceIdentifier
only.
pub unsafe fn prepareCredentialListForServiceIdentifiers( &self, service_identifiers: &NSArray<ASCredentialServiceIdentifier>, )
ASCredentialServiceIdentifier
only.Prepare the view controller to show a list of credentials.
Parameter serviceIdentifiers
: the array of service identifiers.
This method is called by the system to prepare the extension’s view controller to present the list of credentials. A service identifier array is passed which can be used to filter or prioritize the credentials that closely match each service. The service identifier array could have zero or more items. If there are more than one item in the array, items with lower indexes represent more specific identifiers for which a credential is being requested. For example, the array could contain identifiers [m.example.com, example.com] with the first item representing the more specifc service that requires a credential. If the array of service identifiers is empty, it is expected that the credential list should still show credentials that the user can pick from.
Sourcepub unsafe fn prepareCredentialListForServiceIdentifiers_requestParameters(
&self,
service_identifiers: &NSArray<ASCredentialServiceIdentifier>,
request_parameters: &ASPasskeyCredentialRequestParameters,
)
Available on macOS and crate feature ASCredentialServiceIdentifier
and crate feature ASPasskeyCredentialRequestParameters
only.
pub unsafe fn prepareCredentialListForServiceIdentifiers_requestParameters( &self, service_identifiers: &NSArray<ASCredentialServiceIdentifier>, request_parameters: &ASPasskeyCredentialRequestParameters, )
ASCredentialServiceIdentifier
and crate feature ASPasskeyCredentialRequestParameters
only.Prepare the view controller to show a list of passkey and password credentials.
Parameter serviceIdentifiers
: the array of service identifiers.
Parameter requestParameters
: the parameters of the active passkey request.
This method is called by the system to prepare the extension’s view controller to present the list of credentials. A service identifier array is passed which can be used to filter or prioritize the credentials that closely match each service. The service identifier array could have zero or more items. If there is more than one item in the array, items with lower indexes represent more specific identifiers for which a credential is being requested. For example, the array could contain identifiers [m.example.com, example.com] with the first item representing the more specifc service that requires a credential. If the array of service identifiers is empty, it is expected that the credential list should still show credentials that the user can pick from. If a passkey credential is selected, the extension should use the requestParameters object to complete the request using the selected passkey credential.
Sourcepub unsafe fn prepareOneTimeCodeCredentialListForServiceIdentifiers(
&self,
service_identifiers: &NSArray<ASCredentialServiceIdentifier>,
)
Available on macOS and crate feature ASCredentialServiceIdentifier
only.
pub unsafe fn prepareOneTimeCodeCredentialListForServiceIdentifiers( &self, service_identifiers: &NSArray<ASCredentialServiceIdentifier>, )
ASCredentialServiceIdentifier
only.Prepare the view controller to show a list of one time code credentials.
Parameter serviceIdentifiers
: the array of service identifiers.
This method is called by the system to prepare the extension’s view controller to present the list of credentials. A service identifier array is passed which can be used to filter or prioritize the credentials that closely match each service. The service identifier array could have zero or more items. If there is more than one item in the array, items with lower indexes represent more specific identifiers for which a credential is being requested. For example, the array could contain identifiers [m.example.com, example.com] with the first item representing the more specifc service that requires a credential. If the array of service identifiers is empty, it is expected that the credential list should still show credentials that the user can pick from.
Sourcepub unsafe fn provideCredentialWithoutUserInteractionForIdentity(
&self,
credential_identity: &ASPasswordCredentialIdentity,
)
👎DeprecatedAvailable on macOS and crate feature ASPasswordCredentialIdentity
only.
pub unsafe fn provideCredentialWithoutUserInteractionForIdentity( &self, credential_identity: &ASPasswordCredentialIdentity, )
ASPasswordCredentialIdentity
only.Attempt to provide the user-requested credential without any user interaction.
Parameter credentialIdentity
: the credential identity for which a credential should be provided.
After the user selects a credential identity, the system may ask your extension to provide the credential without showing any user interface if possible to enhance the user experience. If your extension can accomplish this (for example, the user’s passwords database is still unlocked from a recent interaction), call -[ASCredentialProviderExtensionContext completeRequestWithSelectedCredential:completionHandler:] to provide the credential. If an error occurs, call -[ASCredentialProviderExtensionContext cancelRequestWithError:] and pass an error with domain ASExtensionErrorDomain and an appropriate error code from ASExtensionErrorCode. For example, if your extension requires user interaction because the passwords database needs to be unlocked, pass an error with code ASExtensionErrorCodeUserInteractionRequired.
Note: When this method is called, your extension’s view controller is not present on the screen. Do not attempt or expect to show any user interface in this method.
Sourcepub unsafe fn provideCredentialWithoutUserInteractionForRequest(
&self,
credential_request: &ProtocolObject<dyn ASCredentialRequest>,
)
Available on macOS and crate feature ASCredentialRequest
only.
pub unsafe fn provideCredentialWithoutUserInteractionForRequest( &self, credential_request: &ProtocolObject<dyn ASCredentialRequest>, )
ASCredentialRequest
only.Attempt to provide the user-requested credential without any user interaction.
After the user selects a credential identity, the system will create a credential request, the contents of
which will depend on whether the credential to use is a password or passkey. The request type will match
the type of credential that was requested. Refer to ASPasswordCredentialRequest
,
ASPasskeyCredentialRequest
, and ASOneTimeCodeCredentialRequest
for details.
The system may ask your extension to provide the credential without showing any user interface if possible
to enhance the user experience. If your extension can accomplish this (for example, the user’s passwords
database is still unlocked from a recent interaction), call -[ASCredentialProviderExtensionContext completeRequestWithSelectedCredential:completionHandler:]
for password credentials, -[ASCredentialProviderExtensionContext completeAssertionRequestWithSelectedPasskeyCredential:completionHandler:]
for passkey credentials,
or -[ASCredentialProviderExtensionContext completeOneTimeCodeRequestWithSelectedCredential:completionHandler:]
for one time code credentials.
If an error occurs, call -[ASCredentialProviderExtensionContext cancelRequestWithError:]
and pass an error with domain ASExtensionErrorDomain
and an appropriate error code from
ASExtensionErrorCode
. For example, if your extension requires user interaction because the
passwords database needs to be unlocked, pass an error with code ASExtensionErrorCodeUserInteractionRequired
.
In order for your extension to be presented in the list of options for passkey assertion requests, your
extension needs to specify a true value for the Information Property List key ProvidesPasskeys
under the ASCredentialProviderExtensionCapabilities
dictionary.
Info.plist ├─ NSExtension ├─ NSExtensionAttributes ├─ ASCredentialProviderExtensionCapabilities ├─ ProvidesPasskeys => true
Similarly, your extension needs to specify a true value for the Information Property List key ProvidesOneTimeCodes
under the ASCredentialProviderExtensionCapabilities
dictionary in order to be presented in
the list of options for one time code requests.
-
Note: When this method is called, your extension’s view controller is not present on the screen. Do not attempt or expect to show any user interface in this method.
-
Parameter credentialRequest: The credential request for which a credential should be provided.
Sourcepub unsafe fn prepareInterfaceToProvideCredentialForIdentity(
&self,
credential_identity: &ASPasswordCredentialIdentity,
)
👎DeprecatedAvailable on macOS and crate feature ASPasswordCredentialIdentity
only.
pub unsafe fn prepareInterfaceToProvideCredentialForIdentity( &self, credential_identity: &ASPasswordCredentialIdentity, )
ASPasswordCredentialIdentity
only.Prepare the view controller to show user interface for providing the user-requested credential.
Parameter credentialIdentity
: the credential identity for which a credential should be provided.
The system calls this method when your extension cannot provide the requested credential without user interaction. Set up the view controller for any user interaction required to provide the requested credential only. The user interaction should be limited in nature to operations required for providing the requested credential. An example is showing an authentication UI to unlock the user’s passwords database. Call -[ASCredentialProviderExtensionContext completeRequestWithSelectedCredential:completionHandler:] to provide the credential. If an error occurs, call -[ASCredentialProviderExtensionContext cancelRequestWithError:] and pass an error with domain ASExtensionErrorDomain and an appropriate error code from ASExtensionErrorCode. For example, if the credential identity cannot be found in the database, pass an error with code ASExtensionErrorCodeCredentialIdentityNotFound.
Sourcepub unsafe fn prepareInterfaceToProvideCredentialForRequest(
&self,
credential_request: &ProtocolObject<dyn ASCredentialRequest>,
)
Available on macOS and crate feature ASCredentialRequest
only.
pub unsafe fn prepareInterfaceToProvideCredentialForRequest( &self, credential_request: &ProtocolObject<dyn ASCredentialRequest>, )
ASCredentialRequest
only.Prepare the view controller to show user interface for providing the user-requested credential.
Parameter credentialRequest
: the credential request for which a credential should be provided.
The system calls this method when your extension cannot provide the requested credential without user interaction. Set up the view controller for any user interaction required to provide the requested credential only. The user interaction should be limited in nature to operations required for providing the requested credential. An example is showing an authentication UI to unlock the user’s passwords database. Call -[ASCredentialProviderExtensionContext completeRequestWithSelectedCredential:completionHandler:] for password credentials or -[ASCredentialProviderExtensionContext completeAssertionRequestWithSelectedPasskeyCredential:completionHandler:] for passkey credentials. If an error occurs, call -[ASCredentialProviderExtensionContext cancelRequestWithError:] and pass an error with domain ASExtensionErrorDomain and an appropriate error code from ASExtensionErrorCode. For example, if the credential identity cannot be found in the database, pass an error with code ASExtensionErrorCodeCredentialIdentityNotFound.
Sourcepub unsafe fn prepareInterfaceForExtensionConfiguration(&self)
Available on macOS only.
pub unsafe fn prepareInterfaceForExtensionConfiguration(&self)
Prepare the view controller to show user interface when the user enables your extension.
The system calls this method after your extension is enabled by the user in Settings. You can use this method to give the user a chance to configure the extension or to provide credential identities to the system. After the configuration is done, call -[ASCredentialProviderExtensionContext completeExtensionConfigurationRequest].
Note: This method only gets called if your extension supports this functionality by specifying “ASCredentialProviderExtensionShowsConfigurationUI”: YES in its extension attributes.
Sourcepub unsafe fn prepareInterfaceForPasskeyRegistration(
&self,
registration_request: &ProtocolObject<dyn ASCredentialRequest>,
)
Available on macOS and crate feature ASCredentialRequest
only.
pub unsafe fn prepareInterfaceForPasskeyRegistration( &self, registration_request: &ProtocolObject<dyn ASCredentialRequest>, )
ASCredentialRequest
only.Prepare UI to register a passkey for the specified relying party.
The system calls this method when the user selects your extension to use for creating a passkey. In order
for your extension to be presented in the list of options for passkey registration requests, your extension
needs to specify a true value for the Information Property List key ProvidesPasskeys
under the
ASCredentialProviderExtensionCapabilities
dictionary.
Info.plist ├─ NSExtension ├─ NSExtensionAttributes ├─ ASCredentialProviderExtensionCapabilities ├─ ProvidesPasskeys => true
This method will present your extension’s UI for user authentication before creating the passkey. Once the
passkey is created, your extension should call -[ASCredentialProviderExtensionContext completeRegistrationRequestWithSelectedPasskeyCredential:completionHandler:]
with the newly created ASPasskeyCredential object. If an error occurs, call
-[ASCredentialProviderExtensionContext cancelRequestWithError:]
and pass an
error with domain ASExtensionErrorDomain
and an appropriate error code from ASExtensionErrorCode
.
- Parameter registrationRequest: The passkey registration request parameters needed to register a new passkey.
Sourcepub unsafe fn performPasskeyRegistrationWithoutUserInteractionIfPossible(
&self,
registration_request: &ASPasskeyCredentialRequest,
)
Available on macOS and crate feature ASPasskeyCredentialRequest
only.
pub unsafe fn performPasskeyRegistrationWithoutUserInteractionIfPossible( &self, registration_request: &ASPasskeyCredentialRequest, )
ASPasskeyCredentialRequest
only.Perform a conditional passkey registration, if possible.
This method will be called for handling conditional passkey registration requests. A conditional passkey registration request allows your extension to opportunistically register passkeys in the background, if and only if you believe the user is in a good state to do so. Your extension decides can decide what conditions make sense for whether to fulfill or reject this request. For example, an extension may decide to register a passkey only if all of the following conditions are met:
- The user’s vault is currently unlocked.
- The user name for the registration request matches that for an existing saved password.
- The matching saved password was filled recently.
- The user does not already have a passkey for this account.
Fulfilling this request should not remove a user’s saved password for this account, but it may mean that the passkey will be preferred over the password in future AutoFill invocations, if both are supported.
Your extension should complete this request by calling -[ASCredentialProviderExtensionContext completeRegistrationRequestWithSelectedPasskeyCredential:completionHandler:]
or-[ASCredentialProviderExtensionContext cancelRequestWithError:]
, like for standard registration requests.
However, this request is not allowed to show UI and ASExtensionErrorCodeUserInteractionRequired
will be treated
like any other error. The intent of this API is to provide a method of performing a background registration only where easy and
convenient, so no blocking UI or error should ever be shown.
To indicate support for this feature, add SupportsConditionalPasskeyRegistration
under the
ASCredentialProviderExtensionCapabilities
dictionary.
Info.plist ├─ NSExtension ├─ NSExtensionAttributes ├─ ASCredentialProviderExtensionCapabilities ├─ SupportsConditionalPasskeyRegistration => true
Source§impl ASCredentialProviderViewController
Methods declared on superclass NSViewController
.
impl ASCredentialProviderViewController
Methods declared on superclass NSViewController
.
pub unsafe fn initWithNibName_bundle( this: Allocated<Self>, nib_name_or_nil: Option<&NSNibName>, nib_bundle_or_nil: Option<&NSBundle>, ) -> Retained<Self>
pub unsafe fn initWithCoder( this: Allocated<Self>, coder: &NSCoder, ) -> Option<Retained<Self>>
Source§impl ASCredentialProviderViewController
Methods declared on superclass NSResponder
.
impl ASCredentialProviderViewController
Methods declared on superclass NSResponder
.
Source§impl ASCredentialProviderViewController
Methods declared on superclass NSObject
.
impl ASCredentialProviderViewController
Methods declared on superclass NSObject
.
pub unsafe fn new(mtm: MainThreadMarker) -> Retained<Self>
Methods from Deref<Target = ASViewController>§
Sourcepub fn doesNotRecognizeSelector(&self, sel: Sel) -> !
pub fn doesNotRecognizeSelector(&self, sel: Sel) -> !
Handle messages the object doesn’t recognize.
See Apple’s documentation for details.
Methods from Deref<Target = AnyObject>§
Sourcepub fn class(&self) -> &'static AnyClass
pub fn class(&self) -> &'static AnyClass
Dynamically find the class of this object.
§Panics
May panic if the object is invalid (which may be the case for objects
returned from unavailable init
/new
methods).
§Example
Check that an instance of NSObject
has the precise class NSObject
.
use objc2::ClassType;
use objc2::runtime::NSObject;
let obj = NSObject::new();
assert_eq!(obj.class(), NSObject::class());
Sourcepub unsafe fn get_ivar<T>(&self, name: &str) -> &Twhere
T: Encode,
👎Deprecated: this is difficult to use correctly, use Ivar::load
instead.
pub unsafe fn get_ivar<T>(&self, name: &str) -> &Twhere
T: Encode,
Ivar::load
instead.Use Ivar::load
instead.
§Safety
The object must have an instance variable with the given name, and it
must be of type T
.
See Ivar::load_ptr
for details surrounding this.
Sourcepub fn downcast_ref<T>(&self) -> Option<&T>where
T: DowncastTarget,
pub fn downcast_ref<T>(&self) -> Option<&T>where
T: DowncastTarget,
Attempt to downcast the object to a class of type T
.
This is the reference-variant. Use Retained::downcast
if you want
to convert a retained object to another type.
§Mutable classes
Some classes have immutable and mutable variants, such as NSString
and NSMutableString
.
When some Objective-C API signature says it gives you an immutable class, it generally expects you to not mutate that, even though it may technically be mutable “under the hood”.
So using this method to convert a NSString
to a NSMutableString
,
while not unsound, is generally frowned upon unless you created the
string yourself, or the API explicitly documents the string to be
mutable.
See Apple’s documentation on mutability and on
isKindOfClass:
for more details.
§Generic classes
Objective-C generics are called “lightweight generics”, and that’s because they aren’t exposed in the runtime. This makes it impossible to safely downcast to generic collections, so this is disallowed by this method.
You can, however, safely downcast to generic collections where all the
type-parameters are AnyObject
.
§Panics
This works internally by calling isKindOfClass:
. That means that the
object must have the instance method of that name, and an exception
will be thrown (if CoreFoundation is linked) or the process will abort
if that is not the case. In the vast majority of cases, you don’t need
to worry about this, since both root objects NSObject
and
NSProxy
implement this method.
§Examples
Cast an NSString
back and forth from NSObject
.
use objc2::rc::Retained;
use objc2_foundation::{NSObject, NSString};
let obj: Retained<NSObject> = NSString::new().into_super();
let string = obj.downcast_ref::<NSString>().unwrap();
// Or with `downcast`, if we do not need the object afterwards
let string = obj.downcast::<NSString>().unwrap();
Try (and fail) to cast an NSObject
to an NSString
.
use objc2_foundation::{NSObject, NSString};
let obj = NSObject::new();
assert!(obj.downcast_ref::<NSString>().is_none());
Try to cast to an array of strings.
use objc2_foundation::{NSArray, NSObject, NSString};
let arr = NSArray::from_retained_slice(&[NSObject::new()]);
// This is invalid and doesn't type check.
let arr = arr.downcast_ref::<NSArray<NSString>>();
This fails to compile, since it would require enumerating over the array to ensure that each element is of the desired type, which is a performance pitfall.
Downcast when processing each element instead.
use objc2_foundation::{NSArray, NSObject, NSString};
let arr = NSArray::from_retained_slice(&[NSObject::new()]);
for elem in arr {
if let Some(data) = elem.downcast_ref::<NSString>() {
// handle `data`
}
}
Trait Implementations§
Source§impl AsRef<NSObject> for ASCredentialProviderViewController
impl AsRef<NSObject> for ASCredentialProviderViewController
Source§fn as_ref(&self) -> &ASViewController
fn as_ref(&self) -> &ASViewController
Source§impl Borrow<NSObject> for ASCredentialProviderViewController
impl Borrow<NSObject> for ASCredentialProviderViewController
Source§fn borrow(&self) -> &ASViewController
fn borrow(&self) -> &ASViewController
Source§impl ClassType for ASCredentialProviderViewController
impl ClassType for ASCredentialProviderViewController
Source§const NAME: &'static str = "ASCredentialProviderViewController"
const NAME: &'static str = "ASCredentialProviderViewController"
Source§type ThreadKind = dyn MainThreadOnly
type ThreadKind = dyn MainThreadOnly
Source§impl NSEditor for ASCredentialProviderViewController
impl NSEditor for ASCredentialProviderViewController
unsafe fn discardEditing(&self)
unsafe fn commitEditing(&self) -> bool
unsafe fn commitEditingWithDelegate_didCommitSelector_contextInfo( &self, delegate: Option<&AnyObject>, did_commit_selector: Option<Sel>, context_info: *mut c_void, )
unsafe fn commitEditingAndReturnError(&self) -> Result<(), Retained<NSError>>
Source§impl NSObjectProtocol for ASCredentialProviderViewController
impl NSObjectProtocol for ASCredentialProviderViewController
Source§fn isEqual(&self, other: Option<&AnyObject>) -> bool
fn isEqual(&self, other: Option<&AnyObject>) -> bool
Source§fn hash(&self) -> usize
fn hash(&self) -> usize
Source§fn isKindOfClass(&self, cls: &AnyClass) -> bool
fn isKindOfClass(&self, cls: &AnyClass) -> bool
Source§fn is_kind_of<T>(&self) -> bool
fn is_kind_of<T>(&self) -> bool
isKindOfClass
directly, or cast your objects with AnyObject::downcast_ref
Source§fn isMemberOfClass(&self, cls: &AnyClass) -> bool
fn isMemberOfClass(&self, cls: &AnyClass) -> bool
Source§fn respondsToSelector(&self, aSelector: Sel) -> bool
fn respondsToSelector(&self, aSelector: Sel) -> bool
Source§fn conformsToProtocol(&self, aProtocol: &AnyProtocol) -> bool
fn conformsToProtocol(&self, aProtocol: &AnyProtocol) -> bool
Source§fn debugDescription(&self) -> Retained<NSObject>
fn debugDescription(&self) -> Retained<NSObject>
Source§impl NSSeguePerforming for ASCredentialProviderViewController
impl NSSeguePerforming for ASCredentialProviderViewController
unsafe fn prepareForSegue_sender( &self, segue: &NSStoryboardSegue, sender: Option<&AnyObject>, )
unsafe fn performSegueWithIdentifier_sender( &self, identifier: &NSString, sender: Option<&AnyObject>, )
unsafe fn shouldPerformSegueWithIdentifier_sender( &self, identifier: &NSString, sender: Option<&AnyObject>, ) -> bool
Source§impl RefEncode for ASCredentialProviderViewController
impl RefEncode for ASCredentialProviderViewController
Source§const ENCODING_REF: Encoding = <ASViewController as ::objc2::RefEncode>::ENCODING_REF
const ENCODING_REF: Encoding = <ASViewController as ::objc2::RefEncode>::ENCODING_REF
impl DowncastTarget for ASCredentialProviderViewController
impl Eq for ASCredentialProviderViewController
Auto Trait Implementations§
impl !Freeze for ASCredentialProviderViewController
impl !RefUnwindSafe for ASCredentialProviderViewController
impl !Send for ASCredentialProviderViewController
impl !Sync for ASCredentialProviderViewController
impl !Unpin for ASCredentialProviderViewController
impl !UnwindSafe for ASCredentialProviderViewController
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<'a, T> MainThreadOnly for T
impl<'a, T> MainThreadOnly for T
Source§fn mtm(&self) -> MainThreadMarker
fn mtm(&self) -> MainThreadMarker
MainThreadMarker
from the main-thread-only object. Read more