I would like to know about managing user\'s login and logout on IPhone native apps. For example, every time my app is running, the user must be logged in. The information the ap
Personally I get the user to enter their login info once, store it in a preference file then use that saved information when ever the server requests the user to authenticate - if your using NSURLConnection then you can use something like:
-(void)connection:(NSURLConnection *)connection
didReceiveAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge{
if ([challenge previousFailureCount] == 0) {
NSURLCredential *newCredential;
newCredential=[NSURLCredential credentialWithUser:[UserManager getUsername]
password:[UserManager getPassword]
persistence:NSURLCredentialPersistenceNone];
[[challenge sender] useCredential:newCredential
forAuthenticationChallenge:challenge];
} else {
[[challenge sender] cancelAuthenticationChallenge:challenge];
// inform the user that the user name and password
// in the preferences are incorrect
}
}
where [UserManager getUsername] and [UserManager getPassword] are class methods in a class that will load the username and password from a preference file