24 ratings
  • 1
  • 2
  • 3
  • 4
  • 5
5 star 9
4 star 8
3 star 3
2 star 0
1 star 4
Compatible with
  • iOS
  • Android

Facebook SDK 6.2.2

The Outercurve Foundation

Build great social experiences and get more installs by adding Facebook to your app.

The Facebook SDK helps .Net developers build applications that integrate with Facebook.

Learn how to use the Facebook SDK to connect your mobile app or game to Facebook. You can use the Facebook SDK to authenticate your users with Facebook or post status messages directly from your app and more.

Samples

Here are some examples to demostrate how simple is to use Facebook SDK once you have obtained a token.

Please see the included samples for more details on how to get a token.

iOS/Android

using Facebook;
...

// Get your own App ID at developers.facebook.com/apps
const string FacebookAppId = "Your_Id_Here";

// You must get this token authorizing by either using Facebook App or a WebView.
// Please review included samples.
string userToken;

void PostToMyWall ()
{
    FacebookClient fb = new FacebookClient (userToken);
    string myMessage = "Hello from Xamarin";

    fb.PostTaskAsync ("me/feed", new { message = myMessage }).ContinueWith (t => {
        if (!t.IsFaulted) {
            string message = "Great, your message has been posted to you wall!";
            Console.WriteLine (message);
        }
    });
}

void GetMyInfo ()
{
    // This uses Facebook Graph API
    // See https://developers.facebook.com/docs/reference/api/ for more information.
    FacebookClient fb = new FacebookClient (userToken);

    fb.GetTaskAsync ("me").ContinueWith (t => {
        if (!t.IsFaulted) {
            var result = (IDictionary<string, object>)t.Result;
            var result = (IDictionary<string, object>)t.Result;
            string myDetails = string.Format ("Your name is: {0} {1} and your Facebook profile Url is: {3}", 
                                              (string)result["first_name"], (string)result["last_name"], 
                                              (string)result["link"]);
            Console.WriteLine (myDetails);
        }
    });
}

void PrintFriendsNames ()
{
    // This uses Facebook Query Language
    // See https://developers.facebook.com/docs/technical-guides/fql/ for more information.
    var query = string.Format("SELECT uid,name,pic_square FROM user WHERE uid IN (SELECT uid2 FROM friend WHERE uid1={0}) ORDER BY name ASC", "me()");
    FacebookClient fb = new FacebookClient (userToken);

    fb.GetTaskAsync ("fql", new { q = query }).ContinueWith (t => {
        if (!t.IsFaulted) {
            var result = (IDictionary<string, object>)t.Result;
            var data = (IList<object>)result["data"];
            var count = data.Count;
            var message = string.Format ("You have {0} friends", count);
            Console.WriteLine (message);

            foreach (IDictionary<string, object> friend in data)
                Console.WriteLine ((string) friend["name"]);
        }
    });
}

Screenshot generated with PlaceIt.

Release Notes


Version 6.2.2

  • Unified API support (Xamarin.iOS 8.6)
Write a Review

25 reviews

Christophe Jacquelin

Hello,

How to publish an image (SKBitmap) on the user of the mobile wall ? Thank you, Christophe

Posted on: March 27 / Version: 6.2.2
zayen chagra rates this with
  • 1
  • 2
  • 3
  • 4
  • 5

Hello everyone, please feel free to use my sample to get user details via this Facebook SDK

https://github.com/zayenCh/Xamarin-Android-Get-Facebook-user-details/

I do think the official documentation of this Component should be updated according to Facebook policies changes but it doesn't seem to be happening since the last update was in 2015

Posted on: December 28, 2016 / Version: 6.2.2
Sagar Saxena

Does anyone know how to use this library on Xamarin studio?I have been trying to download the package but always Xamarin.facebook package getting installed.I want to share a link over Facebook for IOS and android via Xamarin.forms in Xamarin studio.Kindly suggest, its urgent.

Posted on: October 14, 2016 / Version: 6.2.2
Rajnish Sharma rates this with
  • 1
  • 2
  • 3
  • 4
  • 5

Facebook restricted to share the contents from within the application. Please see the updated facebook policy.

https://developers.facebook.com/policy/#control

https://developers.facebook.com/docs/apps/review/prefill

Posted on: July 5, 2016 / Version: 6.2.2
Frank Schreiner

does this sdk work with the newest facebook graph api 2.5

to query the friends (not the friend list!) of the logged in user? (fql is no longer avaiable from 8. August 2016 :( so the PrintFriendNames sample won't work anymore.) I don't found any possibility to query the friend from out a mobile app. There is only the possibility to query the friends of persons who share their friend-list with the app (https://developers.facebook.com/docs/facebook-login/permissions/v2.2#reference-user_friends). That's very complicated and not practable in my opinion.

Posted on: July 3, 2016 / Version: 6.2.2
Brijesh Mathur

Used this SDK to Post on Facebook and it worked very nicely. But I was just wondering if the SDK is automatically controlling the expiry of token or not. SDK from facebook does this automatically.

Posted on: June 18, 2016 / Version: 6.2.2
Ben Pritchard rates this with
  • 1
  • 2
  • 3
  • 4
  • 5

Rendered useless thanks to Facebook's requirement that apps log in using their own native login SDK - apps using this to log in will get rejected by the Facebook approval process.

Needs updating to reflect that Facebook have changed their rules (again).

Posted on: April 14, 2016 / Version: 6.2.2
Ayal Belling rates this with
  • 1
  • 2
  • 3
  • 4
  • 5

Is there any way I can use this component in iOS with Xamarin's Facebook CoreKit and LoginKit packages? The references in the using statements seem to make it clash. Your component requires "using Facebook" while in iOS the CoreKit and LoginKit packages require "using Facebook.CoreKit and using Facebook.LoginKit". I need the LoginKit and CoreKit for native login in iOS while your Graph API requests are much simpler to use in threads than CoreKit's so I prefer yours for Graph API. In my Android project, the Xamarin Facebook packages are referenced with "using Xamarin.Facebook" which appears to prevent the clash I'm experiencing in my iOS project.

Posted on: February 24, 2016 / Version: 6.2.2
Anton Dashivskyi

How get my info with parameters?

fb.GetTaskAsync ("me", new {???}).ContinueWith

Posted on: January 27, 2016 / Version: 6.2.2
Joel Lansden rates this with
  • 1
  • 2
  • 3
  • 4
  • 5

Useless. Example fails with multiple problems. Solve one, and another pops up. This component is either out of date, or just plain broken.

Posted on: August 1, 2015 / Version: 6.2.2
Milan Gohil

Hi,

In the given sample, when I click on "Facebook Login" button, it redirects to web view and it says "Given URL is not permitted by the application configuration. One or more of the given URLs is not allowed by the app's settings. It must match with the website URL, or the domain must be a subdomain of one of the app's domain."

Can someone guide me what I am missing in my app's configuration in facebook's developer page?

I could not find the exact steps how to use this SDK and what settings I would required to do in developer page of facebook.

Edit : I got to know that I forgot to enable "Embedded browser OAuth Login" and now this got resolved. What I am facing now is : SECURITY WARNING: Please treat the URL above as you would your password and do not share it with anyone.

Thanks Milan Gohil

Posted on: March 4, 2015 / Version: 6.2.2
Srinivas

I will be retrieving friends list of the user in one of my applications, In order to get the list of friends, we shall send the accesstoken, but how the accesstoken validatity can be taken care since my app will allow the users to login first time only.

Posted on: September 19, 2014 / Version: 6.2.1
fulgen ninofranco

How to logout with this version of Facebook SDK.

Posted on: May 14, 2014 / Version: 6.2.1
Manuel Costa

Hi all

in iOS after a few submissions with success we started to receive

"Sorry, the video file you selected is in a format that we don't support."

File format : mov

If we send the same file from "Photos" app, it sends.

Any idea of what can be causing this?

Posted on: May 6, 2014 / Version: 6.2.1
pratik rakte

Very nice, but i am working in xamarin studio for android. i am trying to display array of facebook friends in listview but it is not displaying. What will be the problem?

Posted on: January 27, 2014 / Version: 6.2.1
Robert rates this with
  • 1
  • 2
  • 3
  • 4
  • 5

Works very nicely! I just have one question: If I have a facebook app installed on my phone, how would I be able to automatically sign the user in from that app into mine? That way, when the user installs my app and opens it up for the first time, they will not have to type in their credentials.

Posted on: January 20, 2014 / Version: 6.2.1
yasman aap

I cant use this Code !

I strongly need help to do it ! 1- as every user has e unique access token , how can I retrieve this code? 2- is there any other thing (I mean Code) before these codes? I mean to log in with Facebook.

I Would be appreciate if you don't write for me just some links!

Posted on: January 12, 2014 / Version: 6.2.1
Lukáš Neoproud rates this with
  • 1
  • 2
  • 3
  • 4
  • 5

Very good solutions for iOS. For android i try it tommorow.

BTW: if everything is working good except posting on wall - if you are catching 0Ath exception #100 when youre post Async task - change linking from all asemblies to link SDK only.

Posted on: January 7, 2014 / Version: 6.2.1
Ole Falkerslev Kristensen

Can anybody explain how to logout with this version of Facebook SDK. When I change user in my APP I will force a new Login Facebook Webview to be set up?

Posted on: October 22, 2013 / Version: 6.2.1
Tim Tryzbiak rates this with
  • 1
  • 2
  • 3
  • 4
  • 5

Works great. Some tweaking of the FBWebViewAuthActivity and caching the AccessToken has it working perfect.

bala, if you trim down the LoginSucceded function to simply return the AccessToken without getting the ID, you barely notice the warning. It switches back to the parent activity much quicker.

Thanks!

Posted on: October 19, 2013 / Version: 6.2.1
bala dhivya

Hi,

I tried this example i got an error while logging inside fb account error is:https://www.facebook.com/connect/login_success.html SECURITY WARNING: Please treat the URL above as you would your password and do not share it with anyone.

https://www.facebook.com/connect/blank.html#_=_ this is not working

Posted on: October 3, 2013 / Version: 6.2.1
Stephen Gray rates this with
  • 1
  • 2
  • 3
  • 4
  • 5

Hi Eric, I got that error as well but I tried it again and it worked. I haven't looked at the code I was just 'trying stuff out'. The error does seem to happen a lot. Overall though it seems a pretty good component.

Posted on: September 9, 2013 / Version: 6.2.1
cristian orto

problem solved?? because to me to still get the error

Posted on: June 15, 2013 / Version: 6.2.1
Diego Cibils

Same problem here. "The operation couldn't be completed" when trying to log in.

Posted on: May 2, 2013 / Version: 6.2.1
Eric Fontana

I tried this with my AppId, I just get an error "URL The operation couldn't be completed..." using the sample iOS app provided.

Posted on: April 30, 2013 / Version: 6.2.1