Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/xcode/7.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Xcode 保存后解析云代码不起作用_Xcode_Push Notification_Parse Platform - Fatal编程技术网

Xcode 保存后解析云代码不起作用

Xcode 保存后解析云代码不起作用,xcode,push-notification,parse-platform,Xcode,Push Notification,Parse Platform,嘿,我正在使用Parse作为我的后端,我很喜欢它,但是我对afterSave钩子有一个问题 以下是我正在使用的代码: Parse.Cloud.afterSave ("JGZwoelf",function (request) { Parse.Push.send({ //Selecting the Channel

嘿,我正在使用Parse作为我的后端,我很喜欢它,但是我对afterSave钩子有一个问题

以下是我正在使用的代码:

Parse.Cloud.afterSave ("JGZwoelf",function (request) {

                       Parse.Push.send({
                                       //Selecting the Channel
                                       channels: [ request.object.get('JGZwoelfPush') ],

                                            data: {
                                            //Selecting the Key inside the Class
                                            alert: request.object.get('AusfallInfo')

                                            }
                                       }, {
                                            success: function () {
                                            //Push was send successfully
                                            },

                                            error: function (error) {
                                            //Handle error
                                            throw "Got an error" + error.code + " : " + error.message;
                                            }


                                       });
                       });
每次日志控制台告诉我:结果:

Uncaught收到错误112:缺少频道名称

我只是不明白怎么了!它必须在那个JavaScript代码中。如果我手动输入推送通知,一切正常:/

编辑: Parse.Push.send部分应如下所示:

Parse.Push.send ({
        //Selecting the already existing Push Channel
        channels: ["JGAchtPush"], //This has to be the name of your push channel!!
        data: {
            //Selecting the Key inside the Class
            alert: request.object.get ("AusfallInfo")
        }
    }, {
        success: function () {
            //Push was sent successfully
            //nothing was loged
        },
        error: function (error) {
            throw "Got and error" + error.code + " : " + error.message;
        }
    });
频道名称必须类似于[“exampleChannel”]


提前感谢您提供的帮助:)

afterSave的第一个参数应该是类名,而不是objectId

afterSave的第一个参数应该是类名,而不是objectId

以下是给新朋友(像我一样)的,它与原始问题中的代码完全相同,再加上一些注释,再加上已接受答案的更正。目的是展示一个示例,说明为了在解析云代码中工作,需要更改哪些代码片段。谢谢康斯坦丁·雅各布和布克林特

Parse.Cloud.afterSave ("UserVideoMessage",function (request) { // name of my parse class is "UserVideoMessage"

    Parse.Push.send ({
        //Selecting the already existing Push Channel
        channels: ["admin"], //This has to be the name of your push channel!!
        data: {
            //Selecting the Key inside the Class, this will be the content of the push notification
            alert: request.object.get ("from")
        }
    }, {
        success: function () {
            //Push was sent successfully
            //nothing was loged
        },
        error: function (error) {
            throw "Got and error" + error.code + " : " + error.message;
        }
    });

});

下面是给新来的人(像我一样),它和原来问题中的代码完全一样,再加上一些注释,再加上接受答案的更正。目的是展示一个示例,说明为了在解析云代码中工作,需要更改哪些代码片段。谢谢康斯坦丁·雅各布和布克林特

Parse.Cloud.afterSave ("UserVideoMessage",function (request) { // name of my parse class is "UserVideoMessage"

    Parse.Push.send ({
        //Selecting the already existing Push Channel
        channels: ["admin"], //This has to be the name of your push channel!!
        data: {
            //Selecting the Key inside the Class, this will be the content of the push notification
            alert: request.object.get ("from")
        }
    }, {
        success: function () {
            //Push was sent successfully
            //nothing was loged
        },
        error: function (error) {
            throw "Got and error" + error.code + " : " + error.message;
        }
    });

});