【问题标题】:SFUserAccount is always nilSFUserAccount 始终为零
【发布时间】:2017-09-26 18:38:26
【问题描述】:

我已将我的 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];
}

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

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

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

【问题讨论】:

  • 能否提供您在应用中使用的salesforceSDK链接?

标签: ios objective-c iphone salesforce salesforce-ios-sdk


【解决方案1】:

首先,我认为您可以检查委托 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];

}

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

【讨论】:

    【解决方案2】:

    我找到了答案。他们希望在较新版本的 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]];
        }];
    

    【讨论】:

      猜你喜欢
      • 2016-05-02
      • 2012-01-16
      • 2020-01-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-02-10
      相关资源
      最近更新 更多