Parse.Cloud.play 找不到函数
Parse.Cloud.play can't find function
我想我误解了 .play() 函数中的某些内容。我花了几天时间试图弄清楚这一点。
我在 main.js 中有一个函数的定义设置。
var pvp_module = require('cloud/otherCode.js');
function pushBattleMessage_sum(request, response)
{
pvp_module.PushNotification_BattleMessageExport(request, response);
}
Parse.Cloud.define("PushNotification_BattleMessage", pushBattleMessage_sum);
这会将它发送到另一个运行代码的 otherCode.js。在该代码中,我需要调用第二个 Cloud 函数。
function PushNotification_BattleMessage(request, response)
{
Parse.Cloud.run("push_httpRequest",{request},
{
sucess: function(results)
{
response.success(results);
},
error: function(error)
{
response.error(error);
}
});
}
第二个云函数在 main.js
中定义
Parse.Cloud.define('push_httpRequest',function(request)
{
Parse.Cloud.httpRequest(
{
url: 'http://www.parse.com/',
success: function(httpResponse)
{
console.log(httpResponse.text);
},
error: function(httpResponse)
{
console.error('Request failed with response code ' + httpResponse.status);
}
});
});
我在网上找到的一切都告诉我这应该有效,但在我的测试工具中 html 我总是收到错误 "Uncaught ReferenceError: push_httpRequest is not defined"
此代码的目的是 Android 要求声明推送通知图标必须为黑白。我无法使用服务器端解析来初始化该更改,因此我们通过 httpRequest 为 GCM 设备提供推送通知。如果我可以让我的第一个 Cloud 函数找到第二个,我应该能够将所有这些整合在一起。
据我在文档中所见,Parse.Cloud
对象的 define
方法需要一个函数,该函数应采用两个参数。您的函数 push_httpRequest
没有正确定义。来自 Parse documentation:
define( name, func )
Defines a Cloud Function.
Available in Cloud Code only. Parameters:
- name
<String>
The name of the Cloud Function
- func
<Function>
The Cloud Function to register. This function should take two parameters a Parse.Cloud.FunctionRequest
and Parse.Cloud.FunctionResponse
我想我误解了 .play() 函数中的某些内容。我花了几天时间试图弄清楚这一点。
我在 main.js 中有一个函数的定义设置。
var pvp_module = require('cloud/otherCode.js');
function pushBattleMessage_sum(request, response)
{
pvp_module.PushNotification_BattleMessageExport(request, response);
}
Parse.Cloud.define("PushNotification_BattleMessage", pushBattleMessage_sum);
这会将它发送到另一个运行代码的 otherCode.js。在该代码中,我需要调用第二个 Cloud 函数。
function PushNotification_BattleMessage(request, response)
{
Parse.Cloud.run("push_httpRequest",{request},
{
sucess: function(results)
{
response.success(results);
},
error: function(error)
{
response.error(error);
}
});
}
第二个云函数在 main.js
中定义Parse.Cloud.define('push_httpRequest',function(request)
{
Parse.Cloud.httpRequest(
{
url: 'http://www.parse.com/',
success: function(httpResponse)
{
console.log(httpResponse.text);
},
error: function(httpResponse)
{
console.error('Request failed with response code ' + httpResponse.status);
}
});
});
我在网上找到的一切都告诉我这应该有效,但在我的测试工具中 html 我总是收到错误 "Uncaught ReferenceError: push_httpRequest is not defined"
此代码的目的是 Android 要求声明推送通知图标必须为黑白。我无法使用服务器端解析来初始化该更改,因此我们通过 httpRequest 为 GCM 设备提供推送通知。如果我可以让我的第一个 Cloud 函数找到第二个,我应该能够将所有这些整合在一起。
据我在文档中所见,Parse.Cloud
对象的 define
方法需要一个函数,该函数应采用两个参数。您的函数 push_httpRequest
没有正确定义。来自 Parse documentation:
define( name, func )
Defines a Cloud Function.
Available in Cloud Code only. Parameters:
- name
<String>
The name of the Cloud Function- func
<Function>
The Cloud Function to register. This function should take two parameters aParse.Cloud.FunctionRequest
andParse.Cloud.FunctionResponse