Page 1 of 1

Send notifications, filter on array value

Posted: Mon Mar 21, 2016 11:30 am
by Andrew Peacock

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


Send notifications, filter on array value

Posted: Mon Mar 21, 2016 11:39 am
by Andrew Peacock

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

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


Send notifications, filter on array value

Posted: Wed Mar 30, 2016 12:20 pm
by Andrew Peacock

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


Send notifications, filter on array value

Posted: Wed Mar 30, 2016 12:55 pm
by Andrew Peacock

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


Send notifications, filter on array value

Posted: Wed Mar 30, 2016 1:09 pm
by Serhii Kulibaba

Hello Andrew,

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


Send notifications, filter on array value

Posted: Mon Jul 17, 2017 2:50 am
by Deon

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