ParsePush在Unity

时间:2015-08-30 18:29:09

标签: c# exception parse-platform unity3d push-notification

我编写了一个向服务器发送推送通知请求的函数。我正在使用Unity与Parse。当我发送请求时,我得到一个Parse.ParseException:400:错误的请求。

这个想法是向一个玩家发送通知,让他们知道他们已被另一个玩家攻击。谁能看到我做错了什么?

Debug.Log ("<color=#ffa500ff> Sending Push Notification </color>");
    string pushMsg = "You were attacked by " + ServerData.Instance.my_player.username;
    if(!ServerData.Instance.PVP.pvpOpponentData.attackerWon)
        pushMsg += " and lost the fight.";
    else
        pushMsg += " and you won the fight!";

    Debug.Log(pushMsg);

    ParsePush push = new ParsePush();
    push.Query = ParseInstallation.Query.WhereEqualTo("player",ParseObject.CreateWithoutData("player",ServerData.Instance.PVP.pvpOpponentData.targetObjectId));
    push.Data = new Dictionary<string, object> {
        {"title", ServerData.Instance.PVP.pvpOpponentData.bragMessage},
        {"alert", pushMsg}
    };
    push.SendAsync().ContinueWith(p =>
                                  {
        if(sUtil.isNotParseError(p))
        {
            Debug.Log ("<color=#ffa500ff> Push Notification Sent! </color>");
        }
        else
        {
            Debug.Log ("<color=#ffa500ff> Push Notification Failed!\n" + p.Exception.Message + "</color>");
        }
    });

0 个答案:

没有答案