You need to sign in to do that
Don't have an account?
Dhiru47
How to logout in salesforce ios native app
Here is where i am fetching the oauth after logginging
- (void) oauthCoordinatorDidAuthenticate:(SFOAuthCoordinator *)coordinator
{
NSLog(@"Username: %@", coordinator.credentials.userId);
userId_ = [NSString stringWithString:coordinator.credentials.userId];
[superoauthCoordinatorDidAuthenticate:coordinator];
}
Now is there a way to logut progrmatically from the app?
This is what the SFAuthenticationManager class is for. You can call [[SFAuthenticationManager sharedManager] logout], which will clean up app state and raise the kSFUserLogoutNotification (@"kSFUserLogoutOccurred") notification. If you look at the code in AppDelegate.m from either the native sample apps in the SDK workspace, or in the template app that you generate with forceios, you'll see that, in the init method of the class, the app adds an observer for this notification:
And logoutInitiated:, in this instance, brings up the initial set of view state and prompts the user to login again:
Your app, of course, can override this behavior in any way you see fit. But it sounds like this is pretty much the behavior you're hoping to implement in your app, so you should be able to basically copy and paste that code to make it work.
All Answers
Two options:
Then again, that's not really two options -- I think you'd still have to remove all local data even if you do hit the logout endpoint.
Im ravoking the oauth access some thing like this.
- (void)oauthCoordinatorDidAuthenticate:(SFOAuthCoordinator *)coordinator{
[coordinator revokeAuthentication];
}
Sure; same way you presented it to start with.
-(void)logoutofTheApp
{
[[[SFRestAPI sharedInstance] coordinator] revokeAuthentication];
[[[SFRestAPI sharedInstance] coordinator] authenticate];
}
it doesnt popout the login screen , it gives me a warning
2013-09-27 11:12:00.301 CareWeb[21446:c07] oauthCoordinator:didBeginAuthenticationWithView
2013-09-27 11:12:00.302 CareWeb[21446:c07] Warning: Attempt to present <SFAuthorizingViewController: 0x8451c50> on <SFNativeRootViewController: 0x82315b0> whose view is not in the window hierarchy!
This is what the SFAuthenticationManager class is for. You can call [[SFAuthenticationManager sharedManager] logout], which will clean up app state and raise the kSFUserLogoutNotification (@"kSFUserLogoutOccurred") notification. If you look at the code in AppDelegate.m from either the native sample apps in the SDK workspace, or in the template app that you generate with forceios, you'll see that, in the init method of the class, the app adds an observer for this notification:
And logoutInitiated:, in this instance, brings up the initial set of view state and prompts the user to login again:
Your app, of course, can override this behavior in any way you see fit. But it sounds like this is pretty much the behavior you're hoping to implement in your app, so you should be able to basically copy and paste that code to make it work.
Which version of the SDK are you using?
Unless there's a good reason to use an old version of the Mobile SDK, you should use the latest stable version (2.x).