I have the following code:
[[[PFFacebookUtils logInInBackgroundWithAccessToken:[FBSDKAccessToken currentAccessToken]] continueWithSuccessBlock:^id(BFTask *task) {
PFUser *user = task.result;
return user;
}] continueWithSuccessBlock:^id(BFTask *task) {
BFTaskCompletionSource *source = [BFTaskCompletionSource taskCompletionSource];
FBSDKGraphRequest *request = [[FBSDKGraphRequest alloc] initWithGraphPath:@"me" parameters:nil];
[request startWithCompletionHandler:^(FBSDKGraphRequestConnection *connection, id result, NSError *error) {
if (error) {
[source setError:error];
return;
}
[source setResult:result];
}];
return source.task;
}];
The FBSDKGraphRequest works fine outside of the Bolts task, but inside the task the startWithCompletionHandler is not being called.
Any ideas?
I found a workaround. Just wrap it within a main thread block. It will work like a charm.
dispatch_async(dispatch_get_main_queue(), ^{
FBSDKGraphRequest *request = [[FBSDKGraphRequest alloc] initWithGraphPath:@"me" parameters:nil];
[request startWithCompletionHandler:^(FBSDKGraphRequestConnection *connection, id result, NSError *error) {
if (error) {
[source setError:error];
return;
}
[source setResult:result];
}];
});
We had the same exact issue and we used the same solution but I can not seem to find any posts which explain why this is happening.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With