2017-09-26 124 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]]; 
    }];