Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @interface SalesforceManager : NSObject <SFAuthenticationManagerDelegate, SFUserAccountManagerDelegate, SFRestDelegate>
- - (id)init
- {
- self = [super init];
- if(self)
- {
- [SFLogger setLogLevel:SFLogLevelDebug];
- // These SFAccountManager settings are the minimum required to identify the Connected App.
- [SFUserAccountManager sharedInstance].oauthClientId = RemoteAccessConsumerKey;
- [SFUserAccountManager sharedInstance].oauthCompletionUrl = OAuthRedirectURI;
- [SFUserAccountManager sharedInstance].scopes = [NSSet setWithObjects:@"web", @"api", nil];
- // Auth manager delegate, for receiving logout and login host change events.
- [[SFAuthenticationManager sharedManager] addDelegate:self];
- [[SFUserAccountManager sharedInstance] addDelegate:self];
- }
- return self;
- }
- - (void)attemptLoginOnSuccess:(SFManagerLoginSuccessBlock)successBlock
- onFailure:(SFManagerLoginFailBlock)failureBlock
- {
- __weak SalesforceManager *weakSelf = self;
- self.initialLoginSuccessBlock = ^(SFOAuthInfo *info)
- {
- weakSelf.authenticated = TRUE;
- successBlock();
- };
- self.initialLoginFailureBlock = ^(SFOAuthInfo *info, NSError *error)
- {
- [[SFAuthenticationManager sharedManager] logout];
- weakSelf.authenticated = FALSE;
- failureBlock();
- };
- [[SFAuthenticationManager sharedManager] loginWithCompletion:self.initialLoginSuccessBlock failure:self.initialLoginFailureBlock];
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement