SFUserAccountManager loses its details in once app is terminated

119 Views Asked by At

I have an iPad app with Salesforcemobilesdk-ios integrated. First time, as soon as I login I set all the credentials in oauthCoordinatorDidAuthenticate method like this -

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

    [SFAuthenticationManager sharedManager].coordinator = coordinator;
    [[SFAuthenticationManager sharedManager] coordinator].credentials = coordinator.credentials;
    SFUserAccount *userAccount = [[SFUserAccount alloc]initWithIdentifier:s_currentAccountIdentifier];
    userAccount.credentials = coordinator.credentials;
    userAccount.accessScopes = coordinator.scopes;
    [SFUserAccountManager sharedInstance].currentUser = userAccount;
    [[SFUserAccountManager sharedInstance] applyCredentials:coordinator.credentials];
    [[SFUserAccountManager sharedInstance] saveAccounts:nil];
}

It works fine when I try and check valid OAuth session when I am using or in background.

But when I close the app(app terminated) and launch it again, SFUserAccountManager couldn't retrieve the details and check for valid session, instead showing salesforce login screen again.

How to make sure that SFUserAccountManager and SFAuthenticationManager saves its details even when I close the app and launch it again.

Thanks!

Update I tried calling loadAccounts method in appDidBecomeActive, even then couldn't retrieve the details.

[[SFUserAccountManager sharedInstance] loadAccounts:nil];
0

There are 0 best solutions below