我在Unity工作。Facebook的帖子不能與Facebook中的應用程序一起工作在設備中
我試圖使用Facebook SDK插件將分數發佈到Facebook牆上。
雖然我在安裝了官方Facebook應用程序的情況下使用了一個設備(Nexus7,MotoG),但FB.Feed()
方法不起作用,並且設備中沒有出現對話框。
我試過Facebook Unity SDK on Android - Login fails when FB App installed的解決方案,但它不適用於我。
這裏是我的fblogin
腳本:
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!";
}
}
}
誰能幫助?
你能夠登錄嗎? – JRowan
是的,如果我已經註銷登錄框出現併成功登錄,但...飼料對話框不會出現.... –
把它放在你的腳本,並呼籲CallFBFeed(),當你想飼料提出,但首先填寫你想要的檢查員 – JRowan