I wanted to know, the best methodology (with code sample please) of having a login feature on an iPhone application, that would connect to a server. I am assuming web service sending via SOAP isn't the safest.
Thanks guys
With NSURLRequest / NSMutableURLRequest you can set up authentication using any method you like... here's an HTTP Basic example for getting some XML result.
NSMutableURLRequest * request = [NSMutableURLRequest requestWithURL:url];
[request setHTTPMethod:@"GET"]; // or POST or whatever
[request setValue:@"application/xml" forHTTPHeaderField:@"Accept"];
NSString * userID = @"hello";
NSString * password = @"world";
NSString * authStr = [[[NSString stringWithFormat:@"%@:%@", userID, password] dataUsingEncoding:NSUTF8StringEncoding] base64Encoding];
[request setValue:[NSString stringWithFormat: @"Basic %@", authStr] forHTTPHeaderField:@"Authorization"];
You'll need to read up on HTTP authentication techniques to know what to do to talk to your specific server, but there's nothing wrong with using HTTPS (SSL) + Basic, it's secure.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With