// Using Native Friend Picker Controller void FriendPicker () { var friendController = new FBFriendPickerViewController () { Title = "Pick some friends" }; friendController.LoadData (); friendController.PresentModallyFromViewController (this, true, (sender, donePressed) => { if (!donePressed) InvokeOnMainThread (() => new UIAlertView ("Error", "User canceled.", null, "Ok", null).Show ()); else { var ctrl = sender as FBFriendPickerViewController; foreach (var friend in ctrl.Selection) Console.WriteLine (friend.GetName ()); InvokeOnMainThread (() => new UIAlertView ("Success", "You Picked " + ctrl.Selection.Count () + " friend(s)", null, "Ok", null).Show ()); } }); }
// Pick Friends button handler partial void pickFriendsClick(NSObject sender) { Console.WriteLine("pickFriendsClick"); FBFriendPickerViewController friendPickerController = new FBFriendPickerViewController(); friendPickerController.Title = @"Pick Friends"; friendPickerController.LoadData(); friendPickerController.PresentModally(this, true, delegate(FBViewController sender2, bool donePressed) { if (!donePressed) { return; } string message; if (friendPickerController.Selection.Count == 0) { message = @"<No Friends Selected>"; } else { //string text = ""; StringBuilder text = new StringBuilder(); // we pick up the users from the selection, and create a string that we use to update the text view // at the bottom of the display; note that self.selection is a property inherited from our base class for (uint i = 0; i < friendPickerController.Selection.Count; ++i) { if (text.Length > 0) { text.Append(@", "); } FBGraphObject user = (FBGraphObject)Runtime.GetNSObject(friendPickerController.Selection.ValueAt(i)); text.Append(user.ObjectForKey(new NSString("name")).ToString()); } message = text.ToString(); } UIAlertView alert = new UIAlertView("You Picked:", message, null, "Ok", null); alert.Show(); }); }