问题是您在过滤器的值之后缺少逗号。这是您的代码的更正版本:
// ====================================================================================================
//
// Cloud Code for trignotif, write your code here to customise the GameSparks platform.
//
// For details of the GameSparks Cloud Code API see https://portal.gamesparks.net/docs.htm
//
// ====================================================================================================
var lat = Spark.getData().lat
var long = Spark.getData().long
SendNewNotification()
function SendNewNotification() {
var jsonBody = {
app_id: "asdf-safd-fasd-asfd-sadf",
filters: [{field: "location", radius: "5000", lat: lat, long: long}],
contents: {en: "5000 meters test NYC"}
};
var promise = Spark.getHttp("https://onesignal.com/api/v1/notifications").setHeaders({
"Content-Type": "application/json;charset=utf-8",
"Authorization": "Basic fasdasfd"
}).postJson(jsonBody);
return promise;
}
var response = SendNewNotification().getResponseJson();
Spark.setScriptData("response", response)