【问题标题】:Unity3d AppRequest invite limit on selectUnity3d AppRequest 邀请限制选择
【发布时间】:2017-04-13 15:21:11
【问题描述】:

我对@9​​87654321@ 有疑问。我需要用户只从 Facebook UI 中显示的列表中选择一个朋友,但我无法找到一种方法来查看 Facebook Unity3d SDK。

感谢您的帮助。

public void ShareWithUsers()
{
    FB.AppRequest(

        "Come and join me, i bet u cant beat my score",
        null,
        new List<object>() {"app_users"},
        null,
        null,
        null,
        null,
        ShareWithUsersCallback

    );
}

void ShareWithUsersCallback(IAppRequestResult result)
{   
    if (result.Cancelled)
    {
        Debug.Log("Challenge Cancel");
        GameObject.Find("CallBacks").GetComponent<Text>().text = "Challenge Cancel";
    }
    else if (!String.IsNullOrEmpty(result.Error))
    {
        Debug.Log("Challenge on error");
        GameObject.Find("CallBacks").GetComponent<Text>().text = "Challenge on error";
    }
    else if (!String.IsNullOrEmpty(result.RawResult))
    {
        Debug.Log("Success on challenge");

    }
}

【问题讨论】:

  • 检查您在代码中如何编写“挑战”和“成功”,您可能需要考虑使用相同格式编写所有调试日志,例如:Challenge CancelChallenge Error 和 @ 987654325@.

标签: c# facebook unity3d unity3d-gui unity3d-5


【解决方案1】:

如果您查看FB.AppRequest 的文档,它会解释第四个参数是“to”。

public static void AppRequest(
    string message, 
    OGActionType actionType,
    string objectId,
    IEnumerable<string> to,
    string data = "",
    string title = "",    
    FacebookDelegate<IAppRequestResult> callback = null
)

to 是发送请求的 Facebook ID 列表,如果您留下 null 就像现在一样,发件人将看到一个对话框,允许他/她选择收件人。

因此,在您的情况下,您可以留下null 并让用户选择,或者如果它已经选择(您已经知道他想挑战哪个朋友),那么您需要创建一个列表并添加他的 Facebook ID .

FB.AppRequest(

        "Come and join me, i bet u cant beat my score",
        null,
        new List<object>() {"app_users"},
        new List<string>() {"[id of your friend]"},
        null,
        null,
        null,
        ShareWithUsersCallback

    );

这行new List&lt;object&gt;() {"app_users"} 表示可以将请求发送给已经玩过游戏的人。但如果你删除它,它可能会发送给他的任何朋友。

我看到 some older code 设置了一个 maxRecipients,如果设置为一个,则可以确保用户通过 UI 只选择一个朋友:

FB.AppRequest(
        string message,
        IEnumerable<string> to = null,
        IEnumerable<object> filters = null,
        IEnumerable<string> excludeIds = null,
        int? maxRecipients = null,
        string data = "",
        string title = "",
        FacebookDelegate<IAppRequestResult> callback = null);

但这不再出现在文档中。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多