2017-09-26 123 views
0

我已经更新了我的salesforcesdk-IOS新版本5.3.0。成功登录后,我将在此代表所有这些值 - oauthCoordinatorDidAuthenticate:AUTHINFO:这样,SFUserAccount始终是零

- (void) oauthCoordinatorDidAuthenticate: (SFOAuthCoordinator *) coordinator authInfo:(SFOAuthInfo *)info { 

    [SFAuthenticationManager sharedManager].coordinator = coordinator; 
    [[SFAuthenticationManager sharedManager] coordinator].credentials = coordinator.credentials; 
    [[SFUserAccountManager sharedInstance] applyCredentials:coordinator.credentials]; 
} 

当我尝试验证的refreshtoken currentUser是nil在- (无效),发送:(SFRestRequest *)申请委托:(ID)代表shouldRetry:(BOOL)shouldRetry始终加载,而不是发送请求到Salesforce Salesforce的登录页面。

//如果没有可证实的身份验证凭据,发送之前登录。 SFUserAccount *用户= [SFUserAccountManager sharedInstance] .currentUser;

用户永远是零。如何正确设置使用权限?谢谢!

回答

0

首先,我认为你可以检查委托人oauthCoordinatorDidAuthenticate:authInfo:有效。像:

- (void) oauthCoordinatorDidAuthenticate: (SFOAuthCoordinator *) coordinator authInfo:(SFOAuthInfo *)info { 
print("delegate is worked") 
[SFAuthenticationManager sharedManager].coordinator = coordinator; 
[[SFAuthenticationManager sharedManager] coordinator].credentials = coordinator.credentials; 
[[SFUserAccountManager sharedInstance] applyCredentials:coordinator.credentials]; 

}

这可能会导致用户是零,当委托没有奏效。

+0

这个委托被调用,但useraccount设置不正确.. –

0

我找到了答案。他们期望在更新版本的iOS sdk中明确设置currentUser。我有一个自定义登录屏幕,可以在沙箱和生产之间切换。我正在用这种方法设置用户帐户 -

[[SFAuthenticationManager sharedManager] loginWithCompletion:^(SFOAuthInfo *authInfo,SFUserAccount *userAccount) { 
     [SFSDKCoreLogger i:[self class] format:@"Authentication (%@) succeeded. Launch completed.", authInfo.authTypeDescription]; 
     [SFUserAccountManager sharedInstance].currentUser = userAccount; 
     [SFSecurityLockout setupTimer]; 
     [SFSecurityLockout startActivityMonitoring]; 
     s_loggedIn = YES; 
    } failure:^(SFOAuthInfo *authInfo, NSError *authError) { 
     [SFSDKCoreLogger e:[self class] format:@"Authentication (%@) failed: %@.", (authInfo.authType == SFOAuthTypeUserAgent ? @"User Agent" : @"Refresh"), [authError localizedDescription]]; 
    }];