Facebook SDK for Xamarin.Forms.
Supports Android and iOS.
- Login and AccessToken.
- Graph API.
- Install the nuget package in portable and all platform specific projects.
- Setup all of facebook requirments.
In MainActivity.cs file
protected override void OnCreate(Bundle bundle)
{
TabLayoutResource = Resource.Layout.Tabbar;
ToolbarResource = Resource.Layout.Toolbar;
Stormlion.Facebook.Droid.Platform.Init(this);
base.OnCreate(bundle);
global::Xamarin.Forms.Forms.Init(this, bundle);
LoadApplication(new App());
}
protected override void OnActivityResult(int requestCode, Result resultCode, Intent data)
{
Stormlion.Facebook.Droid.Platform.OnActivityResult(requestCode, resultCode, data);
base.OnActivityResult(requestCode, resultCode, data);
}
In AppDelegate.cs file
public override bool FinishedLaunching(UIApplication app, NSDictionary options)
{
global::Xamarin.Forms.Forms.Init();
LoadApplication(new App());
Stormlion.Facebook.iOS.Platform.FinishedLaunching(app, options);
return base.FinishedLaunching(app, options);
}
public override bool OpenUrl(UIApplication app, NSUrl url, NSDictionary options)
{
Stormlion.Facebook.iOS.Platform.OpenUrl(app, url, options);
return base.OpenUrl(app, url, options);
}
FBLoginManager.CallBack = new FBFacebookCallback
{
Success = () =>
{
Debug.WriteLine("Success!");
new FBGraphRequest
{
GraphPath = "me",
Method = FBHttpMethod.GET,
Parameters = new Dictionary<string, string>
{
{"fields", "email, first_name, last_name, gender" }
},
Completed = (response) =>
{
Debug.WriteLine(response);
}
}.ExecuteAsync();
},
Cancel = () =>
{
Debug.WriteLine("Cancel!");
},
Error = () =>
{
Debug.WriteLine("Errror!");
}
};
FBLoginManager.LoginWithReadPermissions(new List<string> { "public_profile" });
Contributions are welcome!