SFUserAccount Class Reference

Inherits from NSObject
Conforms to NSSecureCoding
Declared in SFUserAccount.h

Overview

Class that represents an account. An account represents a user together with the current community it is logged in.

Other Methods

  accessScopes

The access scopes for this user

@property (nonatomic, copy, nullable) NSSet<NSString*> *accessScopes

Declared In

SFUserAccount.h

  accountIdentity

The unique identifier for this account.

@property (nonatomic, readonly) SFUserAccountIdentity *accountIdentity

Declared In

SFUserAccount.h

  credentials

The credentials associated with this user

@property (nonatomic, strong) SFOAuthCredentials *credentials

Declared In

SFUserAccount.h

  idData

The identity data associated with this user

@property (nonatomic, strong) SFIdentityData *idData

Declared In

SFUserAccount.h

  photo

The user’s photo. Usually store a thumbnail of the user. To set this property use setPhoto:completion:

@property (nonatomic, strong, nullable, readonly) UIImage *photo

Declared In

SFUserAccount.h

  accessRestrictions

The access restriction associated with this user

@property (nonatomic) SFUserAccountAccessRestriction accessRestrictions

Declared In

SFUserAccount.h

  sessionValid

Returns YES if the user has an access token and, presumably, a valid session.

@property (nonatomic, readonly, getter=isSessionValid) BOOL sessionValid

Declared In

SFUserAccount.h

  userDeleted

Indicates if this account was deleted. Returns YES if this account was deleted since being created.

@property (nonatomic, readonly, getter=isUserDeleted) BOOL userDeleted

Declared In

SFUserAccount.h

  loginState

Indicates this user’s current login state.

@property (nonatomic, readonly, assign) SFUserAccountLoginState loginState

Declared In

SFUserAccount.h

– initWithCredentials:

- (instancetype)initWithCredentials:(SFOAuthCredentials *)credentials

Parameters

credentials

The credentials to link with the SFUserAccount.

Return Value

the account instance

Declared In

SFUserAccount.h

– setCustomDataObject:forKey:

Set object in customData dictionary

- (void)setCustomDataObject:(id<NSCoding>)object forKey:(id<NSCopying>)key

Parameters

object

The object to store, must be one of the following: NSString, NSNumber, NSArray, NSDictionary, NSURL, NSNull, NSDate

key

An NSCopying key to store the object at

Declared In

SFUserAccount.h

– removeCustomDataObjectForKey:

Remove a custom data object for a key

- (void)removeCustomDataObjectForKey:(id)key

Parameters

key

The key for the object to remove

Declared In

SFUserAccount.h

– customDataObjectForKey:

Retrieve the object stored in the custom data dictionary

- (nullable id)customDataObjectForKey:(id)key

Parameters

key

The key for the object to retrieve

Return Value

The object for a particular key

Declared In

SFUserAccount.h

– setPhoto:completion:

Sets the user’s photo.

- (void)setPhoto:(UIImage *_Nullable)photo completion:(void ( ^ __nullable ) ( NSError *_Nullable ))completion

Parameters

photo

The user photo, usually the thumbnail of the user.

completion

Optional callback block invoked when the photo has been set. If not set, an error is returned.

Declared In

SFUserAccount.h

Extension Methods

  customData

@property (nonatomic, strong, nullable) NSMutableDictionary *customData

– transitionToLoginState:

Attempts to transition from the current login state to the new login state.

- (BOOL)transitionToLoginState:(SFUserAccountLoginState)newLoginState

Parameters

newLoginState

The new login state to set.

Return Value

YES if the login state change was successful, NO otherwise.

Discussion

Only certain state transitions are allowed. For example, you cannot transition from SFUserAccountLoginStateNotLoggedIn to SFUserAccountLoginStateNotLoggingOut, but you can transition from SFUserAccountLoginStateNotLoggedIn to SFUserAccountLoginStateLoggedIn.

Declared In

SFUserAccount+Internal.h