您可以聲明Cloud Code的功能,如Bjorn發佈的指南(https://www.parse.com/docs/cloud_code_guide#cloud_code)中所述。在這種情況下,爲了幫助你,下面是一個方法定義的例子,它的行爲就像你想要的那樣。
/**
* Send Push Notification
* Required:
* tracking -- Tracking String
* slug -- Slug String
* channel -- Channel String
*/
Parse.Cloud.define("sendNotification", function(request, response) {
// Obviously you don't need to assign these variables, but this is how you access the parameters passed in
var tracking = request.params.tracking;
var slug = request.params.slug;
var channel = request.params.channel;
// Send your push notification here, I'm not gonna write the whole thing for you! :)
// In the callback of your push notification call:
response.success();
// For a successful send and response.error() if it fails or an error occurs
});
要調用此方法在客戶端,假設你使用的是Java,因爲你在你的問題語句中使用Java語法,你可以按照這個模式爲雲代碼指南中(參見前面):
HashMap<String, Object> params = new HashMap<String, Object>();
params.put("tracking", "TRACKING_STRING");
params.put("slug", "SLUG_STRING");
params.put("channel", "CHANNEL_STRING");
ParseCloud.callFunctionInBackground("sendNotification", params, new FunctionCallback<Float>() {
void done(ParseException e) {
if (e == null) {
// Your function was successful
} else {
// Your function failed, handle the error here
}
}
});
但是,如果你只是想從客戶端發送推送通知,你應該只使用解析內置在這裏概述功能:https://parse.com/docs/push_guide#sending/Android
是您瞭解如何去的問題罰款JavaScript中的功能? – iForests
@iForests基於標籤,我想這是關於分析框架。 –
解析js SDK基於Backbone。也許你可以先看看骨幹:) –