iOS facebook graph batch request first request doesn't work

35 Views Asked by At

I have 3 chained requests: 1.fbRequest and 2.meRequest are identical. 3. thirdPartyIdRequest meRequest and thirdPartyIdRequest are dependent on fbRequest.

When this runs, every time fbRequest returns a null response dictionary while meRequest(which is an identical call called a second time) and thirdPartyIdRequest return valid responses. I'm not sure why this is happening.

                NSDictionary *dictionary = @{@"fields": @"id, first_name, middle_name, last_name, email, picture.type(large)"};
                NSDictionary *dictionaryThirdPartyIdRequest = @{};

                FBSDKGraphRequest *fbRequest = [[FBSDKGraphRequest alloc] initWithGraphPath:@"me" parameters:dictionary HTTPMethod:@"GET"];
                FBSDKGraphRequest *meRequest = [[FBSDKGraphRequest alloc] initWithGraphPath:@"me" parameters:dictionary HTTPMethod:@"GET"];
                FBSDKGraphRequest *thirdPartyIdRequest = [[FBSDKGraphRequest alloc]
                                              initWithGraphPath:@"custom_audience_third_party_id"
                                              parameters:dictionaryThirdPartyIdRequest
                                              HTTPMethod:@"GET"];


                FBSDKGraphRequestConnection *connection = [[FBSDKGraphRequestConnection alloc] init];
        //request me
                [connection addRequest:fbRequest
                     completionHandler:^(FBSDKGraphRequestConnection *connection, id result, NSError *error) {
                         //TODO: process me information
                         NSLog(@"result fbRequest %@",(NSDictionary *)result);
                     } batchEntryName:@"fbRequest"];

        //request addRequest:thirdPartyIdRequest ok                    
                [connection addRequest:thirdPartyIdRequest
                     completionHandler:^(FBSDKGraphRequestConnection *connection, id result, NSError *error) {
                         //TODO: process like information
                         NSLog(@"result thirdPartyIdRequest %@",(NSDictionary *)result);
                     } batchParameters:@{@"depends_on" : @"fbRequest"}];

        //request me ok
                [connection addRequest:meRequest
                     completionHandler:^(FBSDKGraphRequestConnection *connection, id result, NSError *error) {
                         //TODO: process like information
                         NSLog(@"result meRequest %@",(NSDictionary *)result);
                     } batchParameters:@{@"depends_on" : @"fbRequest"}];
                [connection start];
0

There are 0 best solutions below