Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I get the Facebook user Id from the Facebook object in the iOS SDK?

Tags:

ios

facebook

sdk

I see that the access token is available in the Facebook object, but I don't see a Facebook user Id.

I could make a graph request to "me" to get the Facebook Id, but I'd prefer not to make the extra api call.

like image 238
MonkeyBonkey Avatar asked Sep 09 '11 15:09

MonkeyBonkey


People also ask

How do I get my Facebook API User ID?

The simplest way to get a copy of the User Profile object is to access the /me endpoint: FB. api('/me', function(response) { }); This will this will return the users name and an ID by default.

What is Facebook SDK for iOS?

The Facebook SDK enables: Facebook Login - Authenticate people with their Facebook credentials. Share and Send dialogs - Enable sharing content from your app to Facebook. App Events - Log events in your application.

Does Facebook SDK use IDFA?

The Facebook SDK includes code to access Apple's Advertising Identifier (IDFA), but that code is only executed in certain situations.


1 Answers

There is an easy way to get this these days; assuming you already have a FBSession open, you could just do this:

[FBRequestConnection startForMeWithCompletionHandler:
  ^(FBRequestConnection *connection, id result, NSError *error)
  {
      NSLog(@"facebook result: %@", result);
  }];
like image 105
Juan Avatar answered Sep 27 '22 16:09

Juan