0

http://hastebin.com/nekofuvono.cs

https://documentation.onesignal.com/reference#create-notification

99% sure this is just a formatting issue because Im new to javascript.

I need to get a gamesparks Event data of "lat" and "long", saved as strings with default calc as USED IN SCRIPT, then create a new notification with that in the filter

Keeps telling me I'm missing a bracket after "property list" on line 18 but I dont see where to put it. I've placed one in every location, deleted white spaces, as many things as I could find on google. Thank you!

Ted Bigham
  • 4,237
  • 1
  • 26
  • 31

1 Answers1

0

The issue is that you are missing a comma after the value for filters. Here is a corrected version of your code:

// ====================================================================================================
//
// 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)
Gdeglin
  • 12,432
  • 5
  • 49
  • 65