I'm using the following code to send a user login to a server, but Apple says that I'm using a private API and will reject the app. How can I resolve this?
would replacing with [NSURLRequest setAllowsAnyHTTPSCertificate:YES forHost:[url host]];
[request setHTTPMethod:@"POST"];
be enough?
@interface NSURLRequest (DummyInterface)
+ (BOOL)allowsAnyHTTPSCertificateForHost:(NSString*)host;
+ (void)setAllowsAnyHTTPSCertificate:(BOOL)allow forHost:(NSString*)host;
@end
and my login code:
// token url
NSURL *url=[NSURL URLWithString:@"http://xxxxxxxx.com/api/token"];
NSData *postData = [post dataUsingEncoding:NSASCIIStringEncoding allowLossyConversion:YES];
NSString *postLength = [NSString stringWithFormat:@"%d", [postData length]];
NSMutableURLRequest *request = [[NSMutableURLRequest alloc] init];
[request setURL:url];
[request setHTTPMethod:@"POST"];
[request setValue:postLength forHTTPHeaderField:@"Content-Length"];
[request setValue:@"application/json" forHTTPHeaderField:@"Accept"];
[request setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"];
[request setHTTPBody:postData];
NSLog(@"url is %@",url),
NSLog(@"request is %@",request),
**[NSURLRequest setAllowsAnyHTTPSCertificate:YES forHost:[url host]];**