使用NSURL sendSynchronousRequest,并且在iOS上使用Adhoc build没有来自服务器的响应
所以我有一个应用程序可以向我的远程服务器发送一个同步请求,并且可以从xcode运行它。问题是,当我归档应用程序并将其发送给TestFlight时,测试人员没有收到响应,而是发出了相同的请求。我使用xcode的“设备”窗口来查看设备中的日志,它提供了一个来自服务器的空对象。我还从浏览器的web客户端发出请求,以证明服务器上没有错误。代码如下:使用NSURL sendSynchronousRequest,并且在iOS上使用Adhoc build没有来自服务器的响应,ios,objective-c,xcode,testflight,Ios,Objective C,Xcode,Testflight,所以我有一个应用程序可以向我的远程服务器发送一个同步请求,并且可以从xcode运行它。问题是,当我归档应用程序并将其发送给TestFlight时,测试人员没有收到响应,而是发出了相同的请求。我使用xcode的“设备”窗口来查看设备中的日志,它提供了一个来自服务器的空对象。我还从浏览器的web客户端发出请求,以证明服务器上没有错误。代码如下: -(NSDictionary *)postData:(NSString *)data toUrl:(NSString *)url { if( nil
-(NSDictionary *)postData:(NSString *)data toUrl:(NSString *)url
{
if( nil == url || nil == data ){ return nil; }
NSString *fullUrl = [NSString stringWithFormat:@"%@%@", [self baseUrl], url];
NSURL * serviceUrl = [NSURL URLWithString:fullUrl];
NSMutableData *dados = [NSMutableData data];
[dados appendData: [data dataUsingEncoding: NSUTF8StringEncoding]];
NSMutableURLRequest * serviceRequest = [NSMutableURLRequest requestWithURL:serviceUrl];
[serviceRequest setValue:@"application/json; charset=UTF-8" forHTTPHeaderField:@"Content-type"];
[serviceRequest setHTTPMethod:@"POST"];
[serviceRequest setHTTPBody:dados];
NSHTTPURLResponse * serviceResponse;
NSError * serviceError;
NSData *dataResponse = [NSURLConnection sendSynchronousRequest:serviceRequest
returningResponse:&serviceResponse
error:&serviceError];
NSString *status = [self statusFamily:serviceResponse.statusCode];
NSDictionary *dataFromResponse = [[QMParser sharedParser] dataToDictionary:dataResponse];
return [NSDictionary dictionaryWithObjectsAndKeys:serviceResponse, @"response",
status, @"status",
dataFromResponse, @"data", nil];
}
由于配置配置文件的原因,我也遇到了类似的问题。我通过在Xcode中自动设置配置文件来解决这个问题,转到项目设置->构建设置->代码签名 我认为TestFlight需要新的临时配置配置文件。在此修复之前,当应用程序发出一般http请求时,应用程序会在临时设置配置文件中未包含的每个设备中崩溃
如果不起作用,请尝试删除所有prov配置文件,并让xcode重新创建它们。在发出请求的另一个方法中,在哪里使用返回的字典。