If you want to implement only text / image sharing, 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. (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 the user cancels their post from the facebook app
- You will not 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 latest SDK that has Unity 4.* support prepared to work with no conflicts with the Android Native Plugin.
- In case you Unity 5 user, you can get latest Facebook SDK for Unity which is requires Unity5.
As soon as you done with importing the Facebook SDK, plugin will automatically detect in your project, and you ready to use the OAuth API described bellow.
It also mean that Unity Facebook SDK 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 based on Unity SDK like for example:
- Posting screenshot in the background
- Posting with auto authentication check
- Few feature not available from Unity SDK like for example:
- Platform-Native Image Posting
- Platform-Native Text Posting
- Scores API
- Likes API
- Ability to use PlayMaker Actions instead coding.
- And all other feature you got with the plugin instead Facebook.
The Facebook OAuth API integration is the same as in the Mobile Social Plugin described in following articles:
- General Features
- Likes API
- Scores API
- Game Gifting API
- Turn-Based Games
- Invite Friends API
Full use example can be founded at the FacebookExample example scene.