5

I am using iOS 6 Social framework for accessing user's Facebook data. I am trying to get likes of the current user within my app using ACAccount and SLRequest. I have a valid Facebook account reference of type ACAccount named facebook, and I'm trying to get user's likes this way:

SLRequest *req = [SLRequest requestForServiceType:SLServiceTypeFacebook requestMethod:SLRequestMethodGET URL:url parameters:nil];
req.account = facebook;
[req performRequestWithHandler:^(NSData *responseData, NSHTTPURLResponse *urlResponse, NSError *error) {
     //my handler code.
}

where url is @"https://graph.facebook.com/me/likes?fields=name"; In my handler, I'm getting this response:

{
error =     {
    code = 2500;
    message = "An active access token must be used to query information about the current user.";
    type = OAuthException;
};
}

Shouldn't access tokens be handled by the framework? I've found a similar post Querying Facebook user data through new iOS6 social framework but it doesn't make sense to hard-code an access token parameter into the URL, as logically the access token/login checking should be handled automatically by the framework. In all examples that I've seen around no one plays with an access token manually:

http://damir.me/posts/facebook-authentication-in-ios-6

iOS 6 Facebook posting procedure ends up with "remote_app_id does not match stored id" error etc.

I am using the iOS6-only approach with the built in Social framework, and I'm not using the Facebook SDK. Am I missing something?

Thanks,

Can.

Community
  • 1
  • 1
Can Poyrazoğlu
  • 33,241
  • 48
  • 191
  • 389

3 Answers3

9

You need to keep a strong reference to the ACAccountStore that the account comes from. If the store gets deallocated, it looks like it causes this problem.

Ethan
  • 5,660
  • 9
  • 44
  • 51
  • This is bit crazy but that was it. any problem if I have ACAccountStore as a property? After I set it as property, it worked perfectly. Thanks @Ethan – HMHero Nov 21 '14 at 03:04
0

Try running on an actual device instead of a simulator. This worked for me.

0

Ensure that your bundle id is input into your Facebook app's configuration. You might have a different bundle id for your dev/debug build.

Paul Shapiro
  • 882
  • 8
  • 15