Configure WebSockets
REST Wrappers for SFAP APIs
Using Key-Value Stores for Secure Data Storage
Dark Mode and Dark Theme Settings
About Multi-User Support
SFUserAccount Class
SFUserAccountManager Class
Hybrid APIs
The SFUserAccountManager class provides methods to access authenticated accounts, add new accounts, log out accounts, and switch between accounts.
To access the singleton SFUserAccountManager instance, send the following message:
1[SFUserAccountManager sharedInstance]| Property | Description |
|---|---|
@property (nonatomic, strong) SFUserAccount *currentUser | The current user account. If the user has never logged in, this property may be nil. |
@property (nonatomic, readonly) NSString *currentUserId | A convenience property to retrieve the current user’s ID. This property is an alias for currentUser.credentials.userId. |
@property (nonatomic, readonly) NSString *currentCommunityId | A convenience property to retrieve the current user’s community ID. This property is an alias for currentUser.communityId. |
@property (nonatomic, readonly) NSArray *allUserAccounts | An NSArray of all the SFUserAccount instances for the app. |
@property (nonatomic, readonly) NSArray *allUserIds | Returns an array that contains all user IDs. |
@property (nonatomic, copy) NSString *activeUserId | The most recently active user ID. If the user that’s specified by activeUserId is removed from the accounts list, this user may be temporarily different from the current user. |
@property (nonatomic, strong) NSString *loginHost | The host to be used for login. |
@property (nonatomic, assign) BOOL retryLoginAfterFailure | A flag that controls whether the login process restarts after it fails. The default value is YES. |
@property (nonatomic, copy) NSString *oauthCompletionUrl | The OAuth callback URL to use for the OAuth login process. Apps can customize this property. By default, the property’s value is copied from the SFDCOAuthRedirectUri property in the main bundle. The default value is @"testsfdc:///mobilesdk/detect/oauth/done". |
@property (nonatomic, copy) NSSet *scopes | The OAuth scopes that are associated with the app. |
Returns the path of the .plist file for the specified user account.
1- (NSString*)
2userAccountPlistFileForUser:(SFUserAccount*)userAdds a delegate to this user account manager.
1- (void)
2addDelegate:(id<SFUserAccountManagerDelegate>)delegateRemoves a delegate from this user account manager.
1- (void)
2removeDelegate:(id<SFUserAccountManagerDelegate>)delegateSets the app-level login host to the value in app settings.
1- (SFLoginHostUpdateResult*)updateLoginHostLoads all accounts.
1- (BOOL)loadAccounts:(NSError**)errorCan be used to create an empty user account if you want to configure all of the account information yourself. Otherwise, use [SFAuthenticationManager loginWithCompletion:failure:] to automatically create an account when necessary.
1- (SFUserAccount*)createUserAccountReturns the user account that’s associated with a given user ID.
1- (SFUserAccount*)
2userAccountForUserId:(NSString*)userIdReturns all accounts that have access to a particular organization.
1- (NSArray*)
2accountsForOrgId:(NSString*)orgIdReturns all accounts that match a particular instance URL.
1- (NSArray *)
2accountsForInstanceURL:(NSString *)instanceURLAdds a user account.
1- (void)addAccount:(SFUserAccount
2*)acctRemoves the user account that’s associated with the given user ID.
1- (BOOL)
2deleteAccountForUserId:(NSString*)userId
3error:(NSError **)errorClears the account’s state in memory (but doesn’t change anything on the disk).
1- (void)clearAllAccountStateApplies the specified credentials to the current user. If no user exists, a user is created.
1- (void)
2applyCredentials:
3(SFOAuthCredentials*)credentialsApplies custom data to the SFUserAccount that can be accessed outside that user’s sandbox. This data persists between app launches. Because this data will be serialized, make sure that objects that are contained in customData follow the NSCoding protocol.
Use this method only for nonsensitive information.
Important
1- (void)applyCustomDataToCurrentUser:
2(NSDictionary*)customDataSwitches from the current user to a new user context.
1- (void)switchToNewUserSwitches from the current user to the specified user account.
1- (void)switchToUser:(SFUserAccount *)newCurrentUserInforms the SFUserAccountManager object that something has changed for the current user.
1- (void)
2userChanged:(SFUserAccountChange)changeWe've Moved