Handling Authentication Errors
| Swift | Objective-C |
|---|---|
| UserAccountManager | SFUserAccountManager |
| UserAccountManagerDelegate | SFUserAccountManagerDelegate |
Mobile SDK provides default error handlers that display messages and divert the app flow when authentication errors occur. In an error event, the user account manager iterates through its delegates and gives them the chance to handle the error.
To insert your own classes into this chain, implement the delegate protocol and override the following method:
1func userAccountManager(_ accountManager: UserAccountManager,
2 didFailAuthenticationWith: Error,
3 info: AuthInfo) -> Bool
4{
5 // Provide custom error handling
6 //...
7 return true
8}1/**
2 *
3 * @param userAccountManager The instance of SFUserAccountManager
4 * @param error The Error that occurred
5 * @param info The info for the auth request
6 * @return YES if the error has been handled by the delegate.
7 * SDK will attempt to handle the error if the result is NO.
8 */
9- (BOOL)userAccountManager:(SFUserAccountManager *)userAccountManager
10 error:(NSError*)error
11 info:(SFOAuthInfo *)info {
12 // Provide custom error handling
13 //...
14 return YES;
15}A return value of true or YES indicates that the method handled the current error condition. In this case, the user account manager takes no further action for this error. Otherwise, the delegate did not handle the error, and the error handling process falls to the next delegate in the list. If all delegates return false, the user account manager uses its own error handler.