- (IBAction)loginAction:(id)sender {
NSString *post =[NSString stringWithFormat:@"Email=%@&Password=%@",self.eMail.text,self.password.text];
NSString * loginURL = @"http://75.101.159.160:8222/api/mobileappapi/user/login"; // Login URL
NSData *postData = [post dataUsingEncoding:NSASCIIStringEncoding allowLossyConversion:YES];
NSHTTPURLResponse * response;
NSError * error;
NSMutableURLRequest * request;
request = [[NSMutableURLRequest alloc]initWithURL:nil cachePolicy:NSURLRequestReloadIgnoringLocalAndRemoteCacheData timeoutInterval:60.0];
[request setHTTPMethod:@"POST"];
[request setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"];
[request setValue:@"application/json" forHTTPHeaderField:@"Accept"];
[request setHTTPBody:postData];
request.URL = [NSURL URLWithString:[NSString stringWithFormat:@"%@",loginURL]];
error = nil;
response = nil;
NSData* jsonUpdateDate = [NSURLConnection sendSynchronousRequest:request returningResponse:&response error:&error];
// jsonUpdateDate = [NSURLConnection sendSynchronousRequest:request returningResponse:response error:&error];
NSDictionary* resultsDictionary = [NSJSONSerialization JSONObjectWithData:jsonUpdateDate options:0 error:&error];
NSLog(@"%@",resultsDictionary);
NSString *userRole = [resultsDictionary objectForKey:@"UserRole"];
if (userRole != (NSString*)[NSNull null]) {
if ([userRole isEqualToString:@"Passenger"]) {
// SuccessuserRole
HomeScreen *obj=[self.storyboard instantiateViewControllerWithIdentifier:@"HomeScreen"];
[self presentViewController:obj animated:NO completion:nil];
}
else if ([userRole isEqualToString:@"Driver"]){
SelectVehicle *obj=[self.storyboard instantiateViewControllerWithIdentifier:@"SelectVehicle"];
[self presentViewController:obj animated:NO completion:nil];
}
}
}
I can not access the service here