簡體   English   中英

SFUserAccount始終為零

[英]SFUserAccount is always nil

我已經將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為零-(void)發送:(SFRestRequest *)請求委托人:(id)委托shouldRetry:(BOOL)shouldRetry並始終加載salesforce登錄頁面而不是將請求發送至Salesforce。

//如果沒有可驗證的身份驗證憑據,請在發送前登錄。 SFUserAccount * user = [SFUserAccountManager sharedInstance] .currentUser;

用戶始終為零。 如何正確設置用戶帳號? 謝謝!

首先,我認為您可以檢查委托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];

}

當委托不起作用時,這可能導致用戶為零。

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM