我目前有一个异步调用来上传照片,该照片只是一个base64编码的字符串,并且它已被调整大小,所以它不是超级巨大,也许800x800或类似的东西。如何使iOS中的RESTkit调用继续,即使主屏幕按钮被按下或手机进入待机状态
我目前遇到的问题是即使上传正常,用户也无法关闭应用程序,点击主页按钮或以其他方式在应用程序运行时离开。然而,他们可以在应用程序中的其他地方工作,我猜这是奖金,但即使他们离开应用程序,我该如何继续此通话?
谢谢!
这里是我的(它的工作),(以及它的工作,如果他们只是坐在那里)
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网络,并且由于RESTKit位于顶端,我必须这样做。