0

我已将我的 salesforcesdk-ios 更新到新版本 5.3.0。成功登录后,我在这个委托中设置了所有这些值 - oauthCoordinatorDidAuthenticate:authInfo:像这样,

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

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

当我尝试验证刷新令牌时,currentUser 为 nil in - (void)send:(SFRestRequest *)request delegate:(id)delegate shouldRetry:(BOOL)shouldRetry并始终加载 salesforce 登录页面而不是向 Salesforce 发送请求。

// 如果没有可证明的身份验证凭据,请在发送前登录。SFUserAccount *user = [SFUserAccountManager sharedInstance].currentUser;

用户始终为零。如何正确设置用户帐户?谢谢!

4

2 回答 2

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];

}

当委托不工作时,它可能导致用户为零。

于 2017-09-26T18:49:22.200 回答
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]];
    }];
于 2017-09-27T15:09:29.030 回答