Andrew Peacock
Posts: 0
Joined: Thu Jan 09, 2014 10:03 pm

Send notifications, filter on array value

Hi,
I've got a field in my devices column which is set to an array. I'd like to send notifications via the REST API to users where they have value X in the array. Can this be done? The docs only seem to indicate "name = vale" filtering.

Regards,
Andy

Andrew Peacock
Posts: 0
Joined: Thu Jan 09, 2014 10:03 pm

Send notifications, filter on array value

Ah, i found the answer. For reference, in the payload section, add:

code
"filter":{
"tags": {"$in":[4,7]}
}
/code

Andrew Peacock
Posts: 0
Joined: Thu Jan 09, 2014 10:03 pm

Send notifications, filter on array value

Hi,
following on from the above, I can't get this to work - the notification is sent, but goes to all devices.

Via postman, the body is:
code
{
"payload": {
"message":"Hello 104!",
"title": "Here is more content",
"badge":"1",
"customData": {
"wp_id": 1
},
"actionButtons":[{
"buttonTitle": "Share",
"buttonIcon": "",
"buttonCallback": "testShow"
}],
"filter":{
"tags": {"$in":[102,105]}
}
}
}
/code

The device is registered with tags: 104, as show in the attached image.

Any idea what's wrong, making this device still receive the notifications?

Regards,
Andy
Image

Andrew Peacock
Posts: 0
Joined: Thu Jan 09, 2014 10:03 pm

Send notifications, filter on array value

Got it sorted.

First, my JSON structure was incorrect.

Second, I had to add an OR clause:

code
{
"payload": {
"message":"Hello 106!",
"title": "Here is more content",
"badge":"1",
"customData": {
"wp_id": 1
}
},
"filter":{
"$or": [
{"tags": {"$in":[104]}},
{"tags": {"$in":[105]}}
]
}
}
/code

Serhii Kulibaba
Posts: 150
Joined: Tue Aug 27, 2013 1:47 pm

Send notifications, filter on array value

Hello Andrew,

Please delete all devices from the DB and send the same request. It works fine on our environment.

Deon
Posts: 0
Joined: Sun Jun 30, 2013 6:00 am

Send notifications, filter on array value

Hi

I have a similar issue. My Rest Service does not like the filter. I have tried the filter in the body as well as in the Query String of the Service.
Image

Return to “Issues”