1
votes

enter image description here . THIS is PLIST

 NSString *post = [NSString stringWithFormat:@"email=%@&password=%@ & user_type=%@",_emailID.text,_password.text, user_type];
    NSData *postData = [post dataUsingEncoding:NSASCIIStringEncoding allowLossyConversion:YES];
    NSString *postLength = [NSString stringWithFormat:@"%lu", (unsigned long)[postData length]];
    NSMutableURLRequest *request = [[NSMutableURLRequest alloc] init];
    [request setURL:[NSURL URLWithString:@"my url"]];
    [request setHTTPMethod:@"POST"];
    [request setValue:postLength forHTTPHeaderField:@"Content-Length"];
    [request setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"];
    [request setHTTPBody:postData];

    NSURLConnection *conn = [[NSURLConnection alloc] initWithRequest:request delegate:self];

    if(conn) {
        NSLog(@"Connection Successful");
    } else {
        NSLog(@"Connection could not be made");
    }

}

- (void)connection:(NSURLConnection *)connection didReceiveData:(NSData*)data{
    [self.receivedData appendData:data];

}

- (void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)error{
    NSLog(@"%@" , error);

}

- (void)connectionDidFinishLoading:(NSURLConnection *)connection{

    NSLog(@"Connected %@",connection); 
}

I'm using this code in my Login form to POST data from email and password fields. i'm facing an error and not getting any response. Error is:

2017-05-01 10:58:06.236 PK.Estate[13412:4023436] App Transport Security has blocked a cleartext HTTP (http://) resource load since it is insecure. Temporary exceptions can be configured via your app's Info.plist file. 2017-05-01 10:58:06.397 PK.Estate[13412:4022282] Error Domain=NSURLErrorDomain Code=-1022 "The resource could not be loaded because the App Transport Security policy requires the use of a secure connection." UserInfo={NSUnderlyingError=0x608000253260 {Error Domain=kCFErrorDomainCFNetwork Code=-1022 "The resource could not be loaded because the App Transport Security policy requires the use of a secure connection." UserInfo={NSErrorFailingURLStringKey=url, NSLocalizedDescription=The resource could not be loaded because the App Transport Security policy requires the use of a secure connection., NSErrorFailingURLKey=url}}, NSErrorFailingURLStringKey=url, NSErrorFailingURLKey=url, NSLocalizedDescription=The resource could not be loaded because the App Transport Security policy requires the use of a secure connection.}

1
You should use HTTPS exclusively. If you must use http then see here: stackoverflow.com/questions/32631184/… for how to do it.Jon Rose
i know there r much more answers on satck overflow and other site i have applied them nut the issue is still thereHamza Imran
i have tried this link also but not working its about 4 days the problem is still there. @JonRoseHamza Imran
isn't email=%@&password=%@ & user_type=%@ should be email=%@&password=%@&user_type=%@ there is space before user_type & after passwordFahim Parkar
if not sure first take backup then remove all your added line from plist which are you have recently add. and follow steps : ** right click on plist > open as source code**. and add on top this line <key>NSAppTransportSecurity</key> <dict> <key>NSAllowsArbitraryLoads</key> <true/> </dict>KKRocks

1 Answers

0
votes

I think you are using http in your url url. If you are using this make changes in plist enter image description here