I am working in Unity.
I tried to post the score to the Facebook wall using Facebook SDK plugin.
Though I used a device (Nexus7, MotoG) with the official Facebook application installed, the FB.Feed()
method is not working and dialog does not appear in device.
I tried the solution on Facebook Unity SDK on Android - Login fails when FB App installed, but it doesn't work for me.
Here is my fblogin
script:
public class fblogin : MonoBehaviour
{
private string status = "Ready";
private string lastResponse = "";
public GUIStyle textStyle = new GUIStyle ();
private Texture2D lastResponseTexture;
private bool isInit = false;
// Use this for initialization
void Start ()
{
}
// Update is called once per frame
void Update ()
{
}
void OnGUI ()
{
if (GUI.Button (new Rect (10, 10, 300, 100), "FB.Init")) {
CallFBInit ();
status = "FB.Init() called with " + FB.AppId;
}
if (GUI.Button (new Rect (100, 100, 300, 100), "Login")) {
//FB.Init (OnInitComplete, OnHideUnity);
//status = "FB.Init() called with " + FB.AppId;
CallFBLogin ();
}
if (GUI.Button (new Rect (200, 200, 300, 100), "Share")) {
//FB.Init (OnInitComplete, OnHideUnity);
//status = "FB.Init() called with " + FB.AppId;
onBragClicked ();
}
}
private void onBragClicked ()
{
//Util.Log ("onBragClicked");
FB.Feed (
linkCaption: "I just smashed " + "15" + " friends! Can you beat it?",
picture: "http://www.friendsmash.com/images/logo_large.jpg",
linkName: "Checkout my Friend Smash greatness!",
link: "http://apps.facebook.com/" + FB.AppId + "/?challenge_brag=" + (FB.IsLoggedIn ? FB.UserId : "guest")
);
}
private void CallFBInit ()
{
FB.Init (OnInitComplete, OnHideUnity);
}
private void OnInitComplete ()
{
Debug.Log ("FB.Init completed: Is user logged in? " + FB.IsLoggedIn);
isInit = true;
}
private void OnHideUnity (bool isGameShown)
{
Debug.Log ("Is game showing? " + isGameShown);
}
private void CallFBLogin ()
{
FB.Login ("email,publish_actions", LoginCallback);
}
void LoginCallback (FBResult result)
{
if (result.Error != null)
lastResponse = "Error Response:\n" + result.Error;
else if (!FB.IsLoggedIn) {
lastResponse = "Login cancelled by Player";
} else {
lastResponse = "Login was successful!";
}
}
}
Can anyone help?