View on Github Documentation Sample Tutorial Getting Started

Windows SDK for Facebook

This SDK brings Facebook integration to app developers creating UWP based apps on both desktop and phone. Easily integrate Facebook Authentication, Like and other Facebook Graph functionality into your Universal apps.


Auth | Dialogs |Graph API


Getting Started

1. Create a new Universal Windows app or open an existing Universal Windows app.

2. Get the SID (Windows Store ID) for your application. Facebook uses the SID of your app as the ID for its redirect URI. You can get the ID for your published app via the process outlined at this URL, but this is not the SID your app will have prior to being signed and submitted to the store.

To get an SID during development, use the following:

using Windows.Security.Authentication.Web;
...
string SID = WebAuthenticationBroker.GetCurrentApplicationCallbackUri().ToString();
        


using namespace Windows::Security::Authentication::Web;
...
String^ SID = WebAuthenticationBroker::GetCurrentApplicationCallbackUri()->DisplayUri;
        

This will return "ms-app://SID"

3. Get the Windows Phone SID for your application

4. Create an app on developers.facebook.com and get an App ID

5. Add the Windows Store ID and Windows Phone Store ID to the Facebook app created.

6. Enable OAuth login

Building the SDK

For Universal Windows Applications for Windows 10 you can use the Nuget package within Visual Studio. Search for "winsdkfb" in the Nuget package explorer and install the package for your project. Alternatively you can grab the SDK directly from Github and add the following project to your solution
  • winsdkfb\winsdkfb\winsdkfb_uwp\winsdkfb_uwp.vcxproj
  • For Windows 8.1 Universal Applications add the following vcxproj's to your solution. You can use Visual Studio 2013 or 2015.

    Once you've added the projects to your solution, add a reference to them in your application references. Note that if you are using the following code snippets in C# functions, that the functions have to be marked with 'async' in order to compile and be used correctly.

    You can view the MSDN docs on the await/async keywords here.There is also a blog post on how await/async is necessary with UI dialog boxes, similar to the Facebook auth dialog.