Specifying remote API /createMessage conditions (OR/AND)
Here is my conditions array in my request to pushwoosh:
Right now it only sends the message when all conditions are satisfied. What if I want to make it one or the other?
Like this:
Site ID = 10 AND ( Businesses IN [2] OR Subscriptions IN ['contests'])
--- here is that segment of the request:
[conditions] => Array (
[0] => Array
(
[0] => Site ID
[1] => IN
[2] => Array
(
[0] => 10
)
)
[1] => Array
(
[0] => Subscriptions
[1] => IN
[2] => Array
(
[0] => contests
)
)
[2] => Array
(
[0] => Businesses
[1] => IN
[2] => Array
(
[0] => 2
)
)
)
-
What I did was create a value "none" for tags where users didn't set a value for it. So "none" means "nothing selected" because Pushwoosh doesn't accept a null or empty string when creating conditions.
"conditions": [["siteId", "IN", ["10"]], ["business", "IN", ["2","none"]], ["subscriptions", "IN", ["contests","none"]]]
It will send a push if any of these conditions are true:
siteID=10 and business=2 siteID=10 and subscriptions=contests siteID=10 and business=2 and subscriptions=contests siteId=10 and business=none and subscriptions=none
This is almost what you need except for the last scenario.
If you can spare using another tag there is a workaround but it will require a little bit of logic in your app when setting the value of the tag. Create a new tag that in an ideal world we'd called "business_and_subscription_is_none", but we'll have to settle for "bizsubnone". In your app if both business and subscription settings are empty (or none) then set the tag bizsubnone to 1. It's a bit flag so the default value would be 0 meaning either subscription or business has a value. Then use this condition logic:
"conditions": [["siteId", "IN", ["10"]], ["business", "IN", ["2","none"]], ["subscriptions", "IN", ["contests","none"]], ["bizsubnone", "IN", ["0"]]]
This is the answer to your question although I don't know how it will impact any other conditions you might want to include. But I hope you get the idea and can expand on it.
Please sign in to leave a comment.
Comments
1 comment