Search code examples
iosfacebookfacebook-ios-sdk

How does one retrieve a Facebook id on iOS


I've spent a few hours looking at the Facebook developer pages and looking over the FBSession but I can't see anywhere how to obtain the FBID either via FBSession or in general. How it is done?

Can FBSession even be used to get the FBID or should some other method be used


Solution

  • You need to perform a request for the "me" graph path or you can use the Facebook SDK's convenience method, requestForMe, i.e.

    [[FBRequest requestForMe] startWithCompletionHandler:^(FBRequestConnection *connection, id result, NSError *error) {
        //result contains a dictionary of your user, including Facebook ID.
    }];
    

    note: you should make sure your FBSession is open first.