views:

2322

answers:

2

i just started using Facebook Connect for iPhone. I've been able to create a login/logout button, initiate and resume sessions, and update the Facebook status.

However one thing I can't figure out how to do is detect when I need to ask for extended permission (such as is required for updating user status). Once this is done once for my app, it seems like this is remembered on the server-side, and I no longer have to bug users with a dialog. If I do pop up the dialog when not needed, it shows briefly, then disappears, which has an annoying flashing effect.

So my question is: how can I detect that a user (session?) has already granted such permission?

+4  A: 

Facebook Connect have one method on his API to show this information: facebook.Users.hasAppPermission

See the documentation for more details: http://wiki.developers.facebook.com/index.php/Users.hasAppPermission

To call this API using the FBRequest method use this code:

NSDictionary *params = [NSDictionary dictionaryWithObjectsAndKeys:
      @"status_update"    , @"ext_perm",
      @"1234" , @"uid",
      nil];

[[FBRequest requestWithDelegate:self] call:@"facebook.users.hasAppPermission" 
                                      params:params];

You only have to pass the ext_perm and the uid parameters, all the rest Facebook Connect will solve automatically.

Now to receive the result, you need to implement one callback method:

- (void)request:(FBRequest*)request didLoad:(id)result {

    NSString* StringResult = result;

    NSLog(@"Query returned %@", StringResult);
}

The result will be one String value: "1" if your application it's authorized or "0" if is not.

SEQOY Development Team
A: 

We have developed one class that simplify the original Facebook Connect, creating one single session object that persist on all your applications objects. Also giving to you simple methods to execute simple tasks as login, logout and publish feeds.

One example is to implement a simple login, just call the login method on your session object:

[fbsession login];

This code will open a Facebook Connect dialog and ask your user for the login and password. If the login is sucessfull, all information about this session will be stored and easily acessible on any point of your application.

You can download and see all the documentation here: http://code.google.com/p/fbconnectsession/wiki/About

SEQOY Development Team