0
我在一個系統上工作,系統在系統中發佈新項目時自動發送推送消息。這很好。問題是我必須對軟件包和專業做一些過濾。Telerik推送通知過濾
在第一個過濾器塊中它可以工作,但是它發送到所有匹配1個條件之一的設備。我想要的(並且在測試2 & 3中試過)是隻有當有人擁有軟件包和某個專業時纔會發送。
的Telerik的API的愚蠢的事情是,它只是返回一個HTTP 400這樣的調試非常困難
希望有人能幫助我。
ps。我跳過了一些不相關的代碼/函數代碼片段
function sendNotifications(some parameters)
{
string json = "{";
//Test code 1 - This works
json += "\"Filter\": {";
json += "\"Parameters.softwarePakket\": {\"$in\": [ \"{software_package}\"]},";
json += "\"Parameters.beroepsGroep\": {\"$in\": [\"{profession1}\", \"{profession2}\"]},";
json += "\"Parameters.module\": {\"$in\": [\"{module}\"]}},";
//Test code 2 - This doesn't work
//json += "\"Filter\": {\"$and\":[{\"Parameters.softwarePakket\":\"{software_package}\"},{\"Parameters.beroepsGroep\":\"{profession1}\"}]}";
//Test code 3 - And this doesn't work either
//json += "\"Filter\": \"{\"$and\":[{\"Parameters.softwarePakket\":\"{software_package}\"},{\"Parameters.beroepsGroep\":\"{profession1}\"}]}\"";
//From here its all fine
json += "\"Android\": {\"data\": {\"title\": \"{app_title}\",\"message\": \"{message}\",\"color\": \"#ffffff\",\"largeIcon\": \"{icon}\",\"customData\": \"{type}\"}},";
json += "\"IOS\": {\"aps\": {\"alert\": \"{message}\",\"badge\": \"+1\",\"sound\": \"default\",\"category\": \"{type}\"},\"customData\": \"{type}\"}";
json += "}";
json = json.Replace("{type}", type);
json = json.Replace("{icon}", formatIcon(type));
json = json.Replace("{message}", genericMessage(type));
var request = (HttpWebRequest)WebRequest.Create("http://api.everlive.com/v1/{app_id}/Push/Notifications");
request.Method = "POST";
request.ContentType = "application/json";
request.ContentLength = json.Length;
using (var stream = new StreamWriter(request.GetRequestStream()))
{
stream.Write(json);
stream.Flush();
stream.Close();
}
var response = (HttpWebResponse)request.GetResponse();
var responseString = new StreamReader(response.GetResponseStream()).ReadToEnd();
}