ARTTokenDetails

Objective-C

@interface ARTTokenDetails : NSObject <NSCopying>

Swift

class ARTTokenDetails : NSObject, NSCopying

Contains an Ably Token and its associated metadata.

  • The Ably Token itself. A typical Ably Token string appears with the form xVLyHw.A-pwh7wicf3afTfgiw4k2Ku33kcnSA7z6y8FjuYpe3QaNRTEo4.

    Declaration

    Objective-C

    @property (nonatomic, copy, readonly) NSString *_Nonnull token;

    Swift

    var token: String { get }
  • The timestamp at which this token expires as a NSDate object.

    Declaration

    Objective-C

    @property (nonatomic, readonly, nullable) NSDate *expires;

    Swift

    var expires: Date? { get }
  • The timestamp at which this token was issued as a NSDate object.

    Declaration

    Objective-C

    @property (nonatomic, readonly, nullable) NSDate *issued;

    Swift

    var issued: Date? { get }
  • The capabilities associated with this Ably Token. The capabilities value is a JSON-encoded representation of the resource paths and associated operations. Read more about capabilities in the capabilities docs.

    Declaration

    Objective-C

    @property (nonatomic, copy, readonly, nullable) NSString *capability;

    Swift

    var capability: String? { get }
  • The client ID, if any, bound to this Ably Token. If a client ID is included, then the Ably Token authenticates its bearer as that client ID, and the Ably Token may only be used to perform operations on behalf of that client ID. The client is then considered to be an identified client.

    Declaration

    Objective-C

    @property (nonatomic, copy, readonly, nullable) NSString *clientId;

    Swift

    var clientId: String? { get }
  • A static factory method to create an ARTTokenDetails object from a deserialized TokenDetails-like object or a JSON stringified TokenDetails object. This method is provided to minimize bugs as a result of differing types by platform for fields such as timestamp or ttl. For example, in Ruby ttl in the TokenDetails object is exposed in seconds as that is idiomatic for the language, yet when serialized to JSON using to_json it is automatically converted to the Ably standard which is milliseconds. By using the fromJson method when constructing an TokenDetails object, Ably ensures that all fields are consistently serialized and deserialized across platforms.

    Declaration

    Objective-C

    + (ARTTokenDetails *_Nullable)fromJson:(nonnull id<ARTJsonCompatible>)json
                                     error:(NSError *_Nullable *_Nullable)errorPtr;

    Swift

    class func fromJson(_ json: ARTJsonCompatible) throws -> ARTTokenDetails

    Parameters

    json

    A deserialized TokenDetails-like object or a JSON stringified TokenDetails object.

    errorPtr

    A reference to the NSError object where an error information will be saved in case of failure.

    Return Value

    An Ably authentication token.