I have an issue with the ‘post to wall’ functionality of the SDK. I have a very simple game, and the posts to the wall works. However, there’s a couple problems.
-
I get TWO dialogs with this current code. One that says “post to timeline”, which has all the relevant info in the CallFBFeed method, and then once you post, you get a second dialog, and the only differences is in the design of the dialog, and the title which is “Post to Wall”.
-
The first dialog is overlaying the game, and the game is still accepting clicks right through the dialog. The second dialog grays the game (the whole browser window actually) and allows you to click anywhere but only accepts clicks in the dialog.
I want the functionality of #2, but only #2. What am I doing wrong?
public class FacebookManager : MonoBehaviour {
public bool isInit = false;
public string FeedToId = "";
public string FeedLink = "";
public string FeedLinkName = "";
public string FeedLinkCaption = "";
public string FeedLinkDescription = "";
public string FeedPicture = "";
public string FeedMediaSource = "";
public string FeedActionName = "";
public string FeedActionLink = "";
public string FeedReference = "";
public bool IncludeFeedProperties = false;
private Dictionary<string, string[]> FeedProperties = new Dictionary<string, string[]>();
//private string status = "Ready";
private string lastResponse = "";
private Texture2D lastResponseTexture;
public string ApiQuery = "";
public static FacebookManager use;
void Start(){
use = this;
}
public void PostToFacebook(){
if(GameManager.use.soundEffectsOn) GameManager.use.GUIAudio.audio.Play();
if(isInit) {
CallFBFeed ();
}
else{
CallFBLogin ();
}
}
public void CallFBInit()
{
FB.Init(OnInitComplete, OnHideUnity);
}
private void OnInitComplete()
{
Debug.Log("FB.Init completed: Is user logged in? " + FB.IsLoggedIn);
isInit = true;
//FB Initialized. Let's login if we're not.
//if(!FB.IsLoggedIn) CallFBLogin();
}
private void OnHideUnity(bool isGameShown)
{
FbDebug.Log("OnHideUnity");
if (!isGameShown)
{
// pause the game - we will need to hide
Time.timeScale = 0;
}
else
{
// start the game back up - we're getting focus again
Time.timeScale = 1;
}
}
private void CallFBLogin()
{
FB.Login("publish_actions", LoginCallback);
}
void LoginCallback(FBResult result)
{
if (result.Error != null)
lastResponse = "Error Response:
" + result.Error;
else if (!FB.IsLoggedIn) {
lastResponse = “Login cancelled by Player”;
} else if(FB.IsLoggedIn){
//Logged in successfully. Let’s post a story.
CallFBFeed();
}
}
private void CallFBLogout()
{
FB.Logout();
}
private void CallFBFeed()
{
Dictionary<string, string[]> feedProperties = null;
if (IncludeFeedProperties)
{
feedProperties = FeedProperties;
}
FB.Feed(
toId: FeedToId,
link: "placeholder",
linkName: "placeholder",
linkCaption: "placeholder",
linkDescription: "placeholder",
picture: "placeholder",
mediaSource: FeedMediaSource,
actionName: "placeholder",
actionLink: "placeholder",
reference: FeedReference,
properties: feedProperties,
callback: Callback
);
}
void Callback(FBResult result)
{
lastResponseTexture = null;
if (result.Error != null)
lastResponse = "Error Response:
" + result.Error;
else if (!ApiQuery.Contains(“/picture”))
lastResponse = "Success Response:
" + result.Text;
else
{
lastResponseTexture = result.Texture;
lastResponse = "Success Response:
";
}
}