【发布时间】:2014-09-12 18:01:14
【问题描述】:
我目前有一个异步调用来上传照片,照片只是一个 base64 编码的字符串,并且它已经调整大小,所以它不是超级大,可能是 800x800 或类似的东西。
我目前遇到的问题是,即使上传成功,用户也无法关闭应用程序,点击主页按钮,或者在应用程序运行时离开应用程序。然而,他们可以在应用程序的其他地方工作,我想这是一个奖励,但是即使他们离开应用程序,我如何让这个呼叫继续?
谢谢!
这是我拥有的代码(它正在工作),(如果他们只是坐在那里,它就可以工作)
NSMutableURLRequest *request = [gad.globalObjectManager requestWithObject:nil method:RKRequestMethodPOST path:@"/api/photo/SavePhoto" parameters:paramsSave];
[request setTimeoutInterval:6000];
AFHTTPRequestOperation *operation = [gad.globalClient HTTPRequestOperationWithRequest:request success:^(AFHTTPRequestOperation *operation, id responseObject) {
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Photo Upload" message:@"Your photo was successfuly uploaded" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
[alert show];
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Photo Upload" message:@"Your photo took long to upload or the harvest server is down, please try again when you are on a wi-fi connection" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
[alert show];
}];
[gad.globalClient enqueueHTTPRequestOperation:operation];
我使用可变请求的原因是为了增加超时,我读过其他文章说如果我需要更大的超时,我必须直接去 AF Networking,因为 RESTKit 位于顶部,所以我必须这样做.
【问题讨论】:
标签: objective-c restkit afnetworking restkit-0.20