2013-03-03 4 views
1

안녕하세요 저는 파스를 백엔드로 사용하고 있는데, 나는 그것을 좋아하지만 afterSave 후크에 문제가 있습니다.Parse Cloud 코드 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; 
              } 


             }); 
         }); 

로그 콘솔이 말해 때마다 : 결과 : 누락 된 채널 이름 :

catch되지는 error112있어 여기

내가 사용하고 코드입니다.

나는 단지 무엇이 잘못되었는지 이해하지 못합니다! 해당 자바 스크립트 코드에 있어야합니다. 내가 푸시 알림을 입력하면 수동으로 모든 작동합니다 :/

편집 : 부품 Parse.Push.send은 다음과 같아야합니다

채널 이름은 [ "exampleChannel"같은 것을 할 필요가
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; 
     } 
    }); 

]. 주어진 도움에 미리

감사합니다 :)

답변

3

가 afterSave에 첫 번째 인수는 클래스 이름이 아니라 OBJECTID해야한다.

1

다음은 (나와 같은) 새로운 사람들을위한 것입니다. 원래의 질문과 똑같은 코드와 몇 가지 더 많은 설명과 허용 된 답변의 수정입니다. 목적은 파스 클라우드 코드에서 작동하기 위해 몇 가지 코드를 변경해야하는 예제를 보여주는 것입니다. 콘스탄틴 야곱과 bklimt 고맙습니다.

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; 
     } 
    }); 

}); 
관련 문제