If you want to implement only text / image sharing, and you do not need to know whether a user posted the message or cancelled the posting sequence. In this case, you can use native platform API. (ACTION_SEND).
- 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
- You can only prompt user to post messages / images to facebook.
- You will not know or be able to respond if a user cancels his post from the facebook app
- You will not be able to post text on Android due to facebook restrictions.
If you decide to go this way, you may use the following API call from anywhere in your project to prompt the user to share a message or image using native android share UI.
Texture2D image = GetImage(); AndroidSocialGate.StartShareIntent("Share", "This is my text to share", image, "facebook.katana");
Note: In some cases Facebook message could be ignored (however, you still can share an image) due to Facebook policy.
The Facebook OAuth API is implemented using Unity Official Facebook SDK
What does it mean?
First of all, in order to use Facebook OAuth API with the Android Native plugin, you need to import FB SDK to your project. You have few options here:
- If you currently using Unity 4.* - import latest Unity Official Facebook SDK v 6.2.2. This is the latest SDK that has Unity 4.* support prepared to work with no conflicts with the Android Native Plugin.
- In case you are a Unity 5 user, you can get the latest Facebook SDK for Unity which requires Unity5.
As soon as you are done with importing the Facebook SDK, plugin will automatically detect in your project, and you wiil be ready to use the OAuth API described below.
It also means that Unity Facebook SDK is integrated with the plugin and has no conflicts, which makes you 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. Like, for example, direct API call using FB.AP method.
And, of course, all other stuff offered by Unity SDK is available for you.
What the difference between Unity SDK and Android Native Plugin Facebook part?
There is couple difference:
- Another workflow.
- Few extra features are based on Unity SDK, for example:
- Posting screenshot in 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 of coding.
- And all other features you got with the plugin instead of Facebook.
The Facebook OAuth API integration is the same as in the Mobile Social Plugin described in the following articles:
- General Features
- Likes API
- Scores API
- Game Gifting API
- Turn-Based Games
- Invite Friends API
Full use example can be found at the FacebookExample example scene.