ARTAuthProtocol
Objective-C
@protocol ARTAuthProtocol
Swift
protocol ARTAuthProtocol
The protocol upon which the ARTAuth is implemented.
-
A client ID, used for identifying this client when publishing messages or for presence purposes. The
clientIdcan be any non-empty string, except it cannot contain a*. This option is primarily intended to be used in situations where the library is instantiated with a key. Note that aclientIdmay also be implicit in a token used to instantiate the library. An error is raised if aclientIdspecified here conflicts with theclientIdimplicit in the token. Find out more about identified clients.Declaration
Objective-C
@property (readonly, nullable) NSString *clientId;Swift
var clientId: String? { get } -
Calls the
requestTokenREST API endpoint to obtain an Ably Token according to the specifiedARTTokenParamsandARTAuthOptions. BothARTTokenParamsandARTAuthOptionsare optional. When omitted ornil, the default token parameters and authentication options for the client library are used, as specified in theARTClientOptionswhen the client library was instantiated, or later updated with an explicit-[ARTAuthProtocol authorize:]request. Values passed in are used instead of, rather than being merged with, the default values. To understand why an AblyARTTokenRequestmay be issued to clients in favor of a token, see Token Authentication explained.Declaration
Objective-C
- (void)requestToken:(nullable ARTTokenParams *)tokenParams withOptions:(nullable ARTAuthOptions *)authOptions callback:(nonnull ARTTokenDetailsCallback)callback;Swift
func requestToken(_ tokenParams: ARTTokenParams?, with authOptions: ARTAuthOptions?, callback: @escaping ARTTokenDetailsCallback)Parameters
tokenParamsAn
ARTTokenParamsobject.authOptionsAn
ARTAuthOptionsobject.callbackA callback for receiving an
ARTTokenDetailsobject. -
See
-[ARTAuthProtocol requestToken:withOptions:callback:]for details.Declaration
Objective-C
- (void)requestToken:(nonnull ARTTokenDetailsCallback)callback;Swift
func requestToken(_ callback: @escaping ARTTokenDetailsCallback)Parameters
callbackA callback for receiving an
ARTTokenDetailsobject. -
Instructs the library to get a new token immediately. When using the realtime client, it upgrades the current realtime connection to use the new token, or if not connected, initiates a connection to Ably, once the new token has been obtained. Also stores any
ARTTokenParamsandARTAuthOptionspassed in as the new defaults, to be used for all subsequent implicit or explicit token requests. AnyARTTokenParamsandARTAuthOptionsobjects passed in entirely replace, as opposed to being merged with, the current client library saved values.Declaration
Objective-C
- (void)authorize:(nullable ARTTokenParams *)tokenParams options:(nullable ARTAuthOptions *)authOptions callback:(nonnull ARTTokenDetailsCallback)callback;Swift
func authorize(_ tokenParams: ARTTokenParams?, options authOptions: ARTAuthOptions?, callback: @escaping ARTTokenDetailsCallback)Parameters
tokenParamsAn
ARTTokenParamsobject.authOptionsAn
ARTAuthOptionsobject.callbackA callback for receiving an
ARTTokenDetailsobject. -
See
-[ARTAuthProtocol authorize:options:callback:]for details.Declaration
Objective-C
- (void)authorize:(nonnull ARTTokenDetailsCallback)callback;Swift
func authorize(_ callback: @escaping ARTTokenDetailsCallback)Parameters
callbackA callback for receiving an
ARTTokenDetailsobject. -
Creates and signs an Ably
ARTTokenRequestbased on the specified (or if none specified, the client library stored)ARTTokenParamsandARTAuthOptions. Note this can only be used when the APIkeyvalue is available locally. Otherwise, the AblyARTTokenRequestmust be obtained from the key owner. Use this to generate an AblyARTTokenRequestin order to implement an Ably Token request callback for use by other clients. BothARTTokenParamsandARTAuthOptionsare optional. When omitted ornil, the default token parameters and authentication options for the client library are used, as specified in theARTClientOptionswhen the client library was instantiated, or later updated with an explicit-[ARTAuthProtocol authorize:]request. Values passed in are used instead of, rather than being merged with, the default values. To understand why an AblyARTTokenRequestmay be issued to clients in favor of a token, see Token Authentication explained.Declaration
Objective-C
- (void)createTokenRequest:(nullable ARTTokenParams *)tokenParams options:(nullable ARTAuthOptions *)options callback:(nonnull void (^)(ARTTokenRequest *_Nullable, NSError *_Nullable))callback;Swift
func createTokenRequest(_ tokenParams: ARTTokenParams?, options: ARTAuthOptions?, callback: @escaping (ARTTokenRequest?, (any Error)?) -> Void)Parameters
tokenParamsAn
ARTTokenParamsobject.optionsAn
ARTAuthOptionsobject.callbackA callback for receiving an
ARTTokenRequestobject. -
See
-[ARTAuthProtocol createTokenRequest:options:callback:]for details.Declaration
Objective-C
- (void)createTokenRequest:(nonnull void (^)(ARTTokenRequest *_Nullable, NSError *_Nullable))callback;Swift
func createTokenRequest(_ callback: @escaping (ARTTokenRequest?, (any Error)?) -> Void)Parameters
callbackA callback for receiving an
ARTTokenRequestobject.