无法向移动设备发送推送通知 - 失败连接到通知:80

时间:2014-07-11 07:05:55

标签: javascript parse-platform

大家都需要你的帮助,我建立新的移动应用程序,我有问题使用javascript使用解析向我的移动应用程序发送通知。我在云代码中下载代码

Parse.Cloud.define("hello", function(request, response) {
Parse.Push.send({channels: [ "AppJSTest" ],data: {
 alert: "Quit Your Jibba Jabba"}}, { success: function() { alert: "success function"},error: function(err) { alert: "fail function"}});  response.success("Hello world!");});

在我的移动应用程序main.js中的文件下面:

   $(document).ready(function() {
Parse.initialize(PARSE_APP, PARSE_JS);

NoteObject = Parse.Object.extend("NoteObject");

function getNotes() {
    var query = new Parse.Query(NoteObject);

    query.find({
        success:function(results) {
            console.dir(results);
            var s = "";
            for(var i=0, len=results.length; i<len; i++) {
                var note = results[i];
                s += "<p>";
                s += "<b>"+note.get("title")+"</b><br/>";
                s += "<b>Written "+note.createdAt + "<br/>";
                s += note.get("body");
                s += "</p>";
            }
            $("#notes").html(s);
        },
        error:function(error) {
            alert("Error when getting notes!");
        }
    });
}

$("#addNoteBtn").on("touchend", function(e) {
    e.preventDefault();

    //Grab the note details, no real validation for now
    var title = $("#noteTitle").val();
    var body = $("#noteBody").val();

    var note = new NoteObject();
    note.save({title:title, body:body}, {
        success:function(object) {
            console.log("Saved the object!");
            $("#noteTitle").val("");
            $("#noteBody").val("");
            getNotes();
        }, 
        error:function(object,error) {
            console.dir(error);
            alert("Sorry, I couldn't save it.");
        }
    });
});

//call getNotes immediately
getNotes();});

我触发从解析命令行手动解析下面的脚本:

curl -X POST \ -H "X-Parse-Application-Id:kNZ1hmD7KFUdf7zcKQG8t19ZPC04itHpcnIrqAqz" \ -H "X-Parse-REST-API-Key:EDrUjXegE1ec01MmlWYo4IqjrG1sphFd3Vkk8OKR" \ -H "Content-Type: application/json" \ -d '{}' \ https://api.parse.com/1/push/hello

我的代码出了什么问题?

1 个答案:

答案 0 :(得分:0)

异步JavaScript每次都能找到你。将response.success(...)移动到您向Parse.Push提供的成功回调中,以便它实际上等待在退出之前提交推送。