TwilioAccessManager Class Reference
Inherits from | NSObject |
---|---|
Declared in | TwilioAccessManager.h |
delegate
Delegate which will receive events related to access token expiry.
@property (nonatomic, assign, nonnull) id<TwilioAccessManagerDelegate> delegate
Discussion
Delegate which will receive events related to access token expiry.
Declared In
TwilioAccessManager.h
currentToken
The current token in use.
@property (nonatomic, strong, readonly, nullable) NSString *currentToken
Discussion
The current token in use.
Declared In
TwilioAccessManager.h
expiryTime
The current token’s expiration time.
@property (nonatomic, strong, readonly, nullable) NSDate *expiryTime
Discussion
The current token’s expiration time.
Declared In
TwilioAccessManager.h
+ accessManagerWithToken:delegate:
Create a new access manager instance with the specified initial token and delegate.
+ (nullable instancetype)accessManagerWithToken:(nonnull NSString *)token delegate:(nonnull id<TwilioAccessManagerDelegate>)delegate
Parameters
token |
String based access token. |
---|---|
delegate |
Delegate to receive lifecycle events. |
Return Value
The new TwilioAccessManager instance.
Discussion
Create a new access manager instance with the specified initial token and delegate.
Declared In
TwilioAccessManager.h
– version
Returns the version of the helper
- (nonnull NSString *)version
Return Value
The access manager version.
Discussion
Returns the version of the helper
Declared In
TwilioAccessManager.h
– shutdown
Terminates all timers and releases any associated listeners.
- (void)shutdown
Discussion
Terminates all timers and releases any associated listeners.
Declared In
TwilioAccessManager.h
– registerClient:forUpdates:
Registers a new listener to receive token updates. This block should maintain a reference to the client(s) you wish to keep updated. You may have one or more listeners for a given access manager.
- (void)registerClient:(nonnull id)client forUpdates:(nonnull TAMUpdateBlock)updateBlock
Parameters
client |
A key to uniquely identify this listener for later removal. Can be the client you wish to update or anything else strongly held by your code. When ‘client’ goes out of scope, so will the listener. |
---|---|
updateBlock |
The update block that will be called when a new token arrives. |
Discussion
Registers a new listener to receive token updates. This block should maintain a reference to the client(s) you wish to keep updated. You may have one or more listeners for a given access manager.
An important note around strong/weak references here. The client identifier should be a STRONGly held object, for instance the Twilio client sdk instance this update listener is for. This allows access manager to stop sending updates to this client when it goes out of scope.
By contrast, any references to your clients within the update block should be WEAK to avoid retain loops which will keep not only your client but this listener in scope until manually removed. For example, the recommended way to use this method is:
TwilioAccessManager *accessManager = [TwilioAccessManager accessManagerWithToken:INIITAL_TOKEN_GOES_HERE delegate:self];
TwilioExampleClient *client = [TwilioExampleClient clientWithToken:accessManager.currentToken];
__weak typeof(client) weakClient = client;
[accessManager registerClient:client forUpdates:^(NSString *updatedToken) {
[weakClient updateToken:updatedToken];
}];
Declared In
TwilioAccessManager.h
– unregisterClient:
Unregisters the specified client from token updates.
- (void)unregisterClient:(nonnull id)client
Parameters
client |
The key that uniquely identifies the listener for removal. |
---|
Discussion
Unregisters the specified client from token updates.
Declared In
TwilioAccessManager.h
– updateToken:
Update the token for this access manager and notify registered listeners.
- (void)updateToken:(nonnull NSString *)token
Parameters
token |
The new access token. |
---|
Discussion
Update the token for this access manager and notify registered listeners.
Declared In
TwilioAccessManager.h