2016-10-03 8 views
0

http://hastebin.com/nekofuvono.csOneSignal 지역 필터 + GameSparks

이 자바 스크립트에 임 때문에 새로운 단지 형식의 문제입니다

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

99 % 확인합니다.

나는 SCRIPT에 사용

이 내게 말하는 유지 한 후 필터에두고 새 알림을 만들 기본 계산과 문자열로 저장, "위도"과 "긴"의 gamesparks 이벤트 데이터를 얻을 필요 18 행의 "속성 목록"뒤에 대괄호가 누락되었습니다. 나는 모든 위치에 하나를 배치하고, 공백을 삭제하고, 구글에서 찾을 수있는 많은 것들을 삭제했다. 고맙습니다!

답변

0

문제는 필터 값 뒤에 쉼표가 누락되었습니다. 다음은 수정 된 코드입니다.

// ==================================================================================================== 
// 
// 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) 
+0

와우. 나는 다른 일을 발견했지만 오. – wvPinky19wv

+0

좀 짭짤한. 남자 – wvPinky19wv