It seems for batch requests, all the parameters are escaped as parts of relative_url, if omit_response_on_success is set to @(false), app will crash with this message: -[__NSCFNumber length]: unrecognized selector
NSDictionary *parameters = [NSMutableDictionary dictionaryWithObjectsAndKeys: @(false), @"omit_response_on_success", nil];
FBRequest *request1 = [FBRequest requestWithGraphPath:self.graphPath
parameters:parameters
HTTPMethod:nil];
[newConnection addRequest:request1 completionHandler:handler batchEntryName:@"entryName"];
If the graphPath is set to @"me/home?omit_response_on_success=0"
, these will be no output from this operation. Any ideas?
是的,SDK当前不支持此选项,请确保为此在https://developers.facebook.com/bugs上提交功能请求。
That should not be a parameter but a key-value in the JSON body of the request, as noted in the docs . I believe the question is rather how to set that key-value in the iOS SDK since we don't have access to the body of the request. From what I could tell there is no way to do it, but I'm not sure if it's a bug.
It's very annoying that Facebook doesn't allow us to set this flag using the iOS SDK. I spent hours trying to figure out a way and this is a little hack I came up with. It should be relatively safe. Just use the RSFBRequestConnection instead of FBRequestConnection:
@interface RSFBRequestConnection : FBRequestConnection
@end
@implementation RSFBRequestConnection
- (NSMutableURLRequest *)urlRequest
{
NSMutableURLRequest *request = [super urlRequest];
NSData *body = request.HTTPBody;
NSString *bodyStr = [[NSString alloc] initWithData:body encoding:NSUTF8StringEncoding];
NSLog(@"%@", bodyStr);
NSString *fixed = [bodyStr stringByReplacingOccurrencesOfString:@"\"relative_url\"" withString:@"\"omit_response_on_success\":false,\"relative_url\""];
request.HTTPBody = [fixed dataUsingEncoding:NSUTF8StringEncoding];
return request;
}
@end
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.