Coding Guidelines

The Facebook API is implemented using Unity Official Facebook SDK

What does it mean?

First of all, Unity Facebook SDK will be imported in your project with the plugin. And the majority of facebook plugin functionality is a wrapper around Unity Facebook implementation.

It also means that Unity Facebook SDK is integrated with the plugin and has no conflicts, which makes you be able to use it (if for some reason you do not like the way facebook stuff is implemented in this plugin). Or use function from Unity Facebook SDK. As, for example, direct API call using FB.AP function.

And, of course, all other stuff offered by Unity SDK is available for you.

 

What is the difference between Unity SDK and Mobile Social Plugin?

There is a couple of differences:

  • Another workflow.
  • Few extra features based on Unity SDK, for example:
    • Posting screenshot in the the background
    • Posting with auto authentication check
  • Few features are not available from  Unity SDK, for example:
    • Platform Native Image Posting
    • Platform Native Text Posting
    • Scores API
    • Likes API
  • Ability to use PlayMaker Actions instead coding.
  • And all other features you got with the plugin instead of Facebook.

There are two general ways you can go with Facebook integration. Pretty much same as Twitter

1) If you want to implement only posting and you do not need to know if a user posted the message or cancelled the posting sequence.  

In this case you can use native platform API.

Advantages:

  • You do not need to create your Facebook app
  • You do not need to prompt user to authenticate with your app with requested permissions before you can use Facebook API
  • User will not leave your app for Facebook authentication.
  • Posting looks natively to platform

Disadvantages

  • You can only prompt user to post messages / images to facebook.
  • You will not know or be able to respond if the user cancels their post from the facebook app.
  • You will not be able to post text on Android, due to facebook restrictions.

Note:  On Android platform posting text may be ignored via Facebook application  due to Facebook policy (they want people to share own thoughts, not the pre-defined text by developer). 

If you decide to go this way, you may use the following API calls from anywhere in your project to prompt the user to tweet a message or image using Facebook’s UI:
 

SPShareUtility.FacebookShare("This is my text to share");
SPShareUtility.FacebookShare("This is my text to share", ImageToShare);

 

Result of this API calls will be similar to the screenshot below:

 

You may read more about the native shared behavior on different platforms at this section.

2)  If you need more and want to use the whole plugin power.

Advantages:

  • You will be able to use all features offered by the plugin
  • More permissions from the user
  • Full control of user actions

Disadvantages

  • You have to create an app on facebook.
  • Extra work with rendering message windows as we are calling API directly.

 

If you decide to go this way, you need to complete Setup Steps before you begin to use Facebook API.

I would recommend creating singleton class which will be responsible for all your game Facebook interactions.