Но ошибка, я думаю, в конце iOS, может ли кто-нибудь указать, что может быть не так?
Проверьте код ниже:
Код: Выделить всё
NSData *datas = [NSJSONSerialization dataWithJSONObject:paramsDic options:NSJSONWritingPrettyPrinted error:nil];
NSString *jsonStrings = [[NSString alloc] initWithData:datas encoding:NSUTF8StringEncoding];
NSString *jencWithPubKey = [EncryptionAlgorithm encryptString:jsonStrings publicKey:APP_PUBLIC_KEY2];
NSData *data1 = [jencWithPubKey dataUsingEncoding:NSUTF8StringEncoding];
NSLog(@"Value of json string %@", jencWithPubKey);
NSMutableURLRequest *urlRequest = [[NSMutableURLRequest alloc] initWithURL:[NSURL URLWithString:QMMemberLogin]];
NSDictionary *heads =@{@"User-Agent":@"Apifox/1.0.0(https://apifox.com)",
@"Content-Type":@"appliction/json; charset=UTF-8",
@"Accept":@"*/*",
@"Conection":@"keep-alive"};
[urlRequest setAllHTTPHeaderFields:heads];
//Apply the data to the body
[urlRequest setHTTPBody:data1];
//create the Method "GET" or "POST"
[urlRequest setHTTPMethod:@"POST"];
NSURLSession *session = [NSURLSession sharedSession];
NSURLSessionDataTask *dataTask = [session dataTaskWithRequest:urlRequest completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *)response;
if(httpResponse.statusCode == 200)
{
NSError *parseError = nil;
NSDictionary *responseDictionary = [NSJSONSerialization JSONObjectWithData:data options:0 error:&parseError];
NSLog(@"The response is - %@",responseDictionary);
NSInteger success = [[responseDictionary objectForKey:@"success"] integerValue];
if(success == 1)
{
NSLog(@"Login SUCCESS");
}
else
{
NSLog(@"Login FAILURE");
}
}
else
{
NSLog(@"Error");
}
}];
[dataTask resume];
Подробнее здесь: https://stackoverflow.com/questions/782 ... uest-error