how to customized fbfrienpickerview controller and show in custom table view - ios

i have got all friends in array
FBRequest* friendsRequest = [FBRequest requestForMyFriends];
[friendsRequest startWithCompletionHandler: ^(FBRequestConnection *connection,
NSDictionary* result,
NSError *error) {
NSArray* friends = [result objectForKey:#"data"];
NSLog(#"Found: %i friends", friends.count);
for (NSDictionary<FBGraphUser>* friend in friends) {
NSLog(#"I have a friend named %# ", friend.name);
how to display in grouped table view in one section.
How to change (tick) friends selection to some custom button of fbfriendpicker view controller

i had the same issue. So i stored all the friends info into a Array (includes dictionaries) and add that data into a UItableView. So same way i think u can do it.

Related

Facebook iOS sdk friends list returns empty

i am using this code for getting Facebook friend list in iOS sdk 8.1.
FBRequest* friendsRequest = [FBRequest requestForMyFriends];
[friendsRequest startWithCompletionHandler: ^(FBRequestConnection *connection,
NSDictionary* result,
NSError *error) {
NSArray* friends = [result objectForKey:#"data"];
NSLog(#"Found: %lu friends", (unsigned long)friends.count);
for (NSDictionary<FBGraphUser>* friend in friends) {
NSLog(#"I have a friend named %# with id %#", friend.name, friend.objectID);
}
}];
but it returns null value.
Since Graph API v2.0, the /{user_id}/friends endpoint does only return those friends who also gave your app the respective permission.
See
https://developers.facebook.com/docs/apps/changelog#v2_0
The /me/friends endpoint no longer includes the full list of a person's friends. Instead, it now returns the list of that person's friends who are also using your app.

Facebook SDk3 how can i get the Facebook all friend list in my tableview and also i want to write some text on the particular friend

how can i get the Facebook all friend list in my iOS Application tableview and also i want to write some text on the particular friend
I'm using Facebook latest sdk
code :
[FBRequestConnection startWithGraphPath:#"/me/friends"
parameters:nil
HTTPMethod:#"GET"
completionHandler:^(FBRequestConnection *connection, id<FBGraphUser> result, NSError *error) {
/* handle the result */
NSLog(#"%#", result);
}];
With Facebook SDK 3.0 you can do this:
FBRequest* friendsRequest = [FBRequest requestForMyFriends];
[friendsRequest startWithCompletionHandler: ^(FBRequestConnection *connection,
NSDictionary* result,
NSError *error) {
NSArray* friends = [result objectForKey:#"data"];
NSLog(#"Found: %i friends", friends.count);
for (NSDictionary<FBGraphUser>* friend in friends) {
NSLog(#"I have a friend named %# with id %#", friend.name, friend.id);
}
}];
Hope this helps..

How to list ALL friends using Graph API 3.x version?

I try to login user to my app with the following permissions:
NSArray* permissions = [[NSArray alloc] initWithObjects:#"email", #"read_friendlists", #"user_friends", nil];
After login I don't get "read_friendlists" permission from
[FBRequestConnection startWithGraphPath:#"/me/permissions"....];
request.
I think this is the reason, why I can't get the full friend list.
I tried to get the list with the following methods:
[FBRequestConnection startWithGraphPath:#"me/friends"
parameters:nil
HTTPMethod:#"GET"
completionHandler:^(
FBRequestConnection *connection,
id result,
NSError *error
) {
NSLog(#"FriendList: %#", result);
/* handle the result */
}];
AND
FBRequest* friendsRequest = [FBRequest requestForMyFriends];
[friendsRequest startWithCompletionHandler: ^(FBRequestConnection *connection,
NSDictionary* result,
NSError *error) {
NSArray* friends = [result objectForKey:#"data"];
NSLog(#"Found: %i friends", friends.count);
for (NSDictionary<FBGraphUser>* friendIns in friends) {
NSLog(#"I have a friend named %# with id %#", friendIns.name, friendIns.id);
}
}];
These methods give me the friends, who also use my app, and not the whole friend list.
What's wrong with my method(s)?
How to get the full friend list from user?
read_friendlists is not for getting friends, but only for getting the lists you created (without any friends in it). It also needs approval from Facebook before you can use it, but it´s definitely not what you want.
user_friends is for getting access to the friends who authorized your App too, with /me/friends. That would be the appropriate way.
There is no way to get ALL friends anymore, unless you want to tag friends (taggable_friends) or invite friends to a game on Facebook Canvas (invitable_friends).

Wait for FB request before UITableView loads

I am trying to use Facebook's iOS SDK and load a list of friends in a UITableView. When I put the following code in viewDidLoad it seemingly doesn't get added to the UITableView. (Where users is the NSMutableArray)
FBRequest* friendsRequest = [FBRequest requestForMyFriends];
[friendsRequest startWithCompletionHandler: ^(FBRequestConnection *connection,
NSDictionary* result,
NSError *error) {
NSArray* friends = [result objectForKey:#"data"];
NSLog(#"Found: %i friends", friends.count);
for (NSDictionary<FBGraphUser>* friend in friends) {
NSLog(#"I have a friend named %# with id %#", friend.name, friend.id);
[users addObject:friend.name];
}
}];
I've tried adding:
[friendsTableView beginUpdates];
[friendsTableView insertRowsAtIndexPaths:users withRowAnimation:UITableViewRowAnimationRight];
[friendsTableView endUpdates];
To update the UITableView after the request finishes with no change.
What can I do either load the UITableView after the request or update the UITableView when the request finishes?
you cannot just pass any array to insertRowsAtIndexPaths:withRowAnimation:. It expects an array filled with index paths — hence the name.
what you want is to reload the tableview once the response is received.
FBRequest* friendsRequest = [FBRequest requestForMyFriends];
[friendsRequest startWithCompletionHandler: ^(FBRequestConnection *connection,
NSDictionary* result,
NSError *error) {
NSArray* friends = [result objectForKey:#"data"];
NSLog(#"Found: %i friends", friends.count);
for (NSDictionary<FBGraphUser>* friend in friends) {
NSLog(#"I have a friend named %# with id %#", friend.name, friend.id);
[users addObject:friend.name];
}
[friendsTableView reloadData]; //<------
}];
while tableviews datasource & delegate methods use users as source.

Load Facebook Friends into an NSMutableArray

I am currently trying to load a user's Facebook friends into an NSMutableArray. However, when I use [users addObject: friend.name]; it doesn't add it to the array outside of the block of code. What am I missing here? Also I am trying to receive the number of friends and this also isn't working outside the block of code. What am I doing wrong here?
FBRequest* friendsRequest = [FBRequest requestForMyFriends];
[friendsRequest startWithCompletionHandler: ^(FBRequestConnection *connection,
NSDictionary* result,
NSError *error) {
NSArray* friends = [result objectForKey:#"data"];
users = [[NSMutableArray alloc] init];
NSLog(#"Found: %i friends", friends.count);
for (NSDictionary<FBGraphUser>* friend in friends) {
NSLog(#"I have a friend named %# with id %#", friend.name, friend.id);
[users addObject:friend.name];
NSLog(#"%#",users);
}
}];
Full code here: http://pastie.org/private/elynlgrkctakioi8pmtta.
yes it is added in the array, but we have to wait sometime to complete the block process. I am fetching friends and storing in NSMutableArray. and use it after some delay of time. I am using below code.
[FBSession setActiveSession:[self appDelegate].session];
FBRequest* friendsRequest = [FBRequest requestForMyFriends];
[friendsRequest startWithCompletionHandler: ^(FBRequestConnection *connection,
NSDictionary* result,
NSError *error) {
NSArray* friends = [result objectForKey:#"data"];
users = [[NSMutableArray alloc] init];
NSLog(#"Found: %i friends", friends.count);
for (NSDictionary<FBGraphUser>* friend in friends)
{
NSLog(#"name : %#",[friend name]);
[tempArray addObject:friend];
}
}];
[self performSelector:#selector(afterFetchingFbFriend:) withObject:tempArray afterDelay:10.0];
in 10.0 delay it completes the block process and i have all the friends in my array.
and then my method to process array is :
-(void)afterFetchingFbFriend:(NSMutableArray *)tempArray
{
//do something.
}
if not getting in 10.0 delay time then increase it as it depends on internet speed so the fetching friends time may be different. It works for me.

Resources