I use the pushwoosh remote API and I can send pushes to all users and to just one device, good! I make apps for schools and I want to be able to send pushes to different classes. For example. Class 4A, Class 4B and Teachers. But now Im trying to be able to send pushes to different groups and Im trying to get "conditions" to work. But Im missing something and I don´t know what!

I have first created a tag called "Grupper" as a listtag(since I want the user to be able to belong to 2 different groups-tags) at pushwoosh. And it is registering the value "Class 4A" and "Class 4B" at pushwoosh from the app as it should.

And this is how I try to send a push from my server to the Class 4A.

var tags="Class 4A"

  var data = {
"request": {
  "application": applicationId,
  "auth": authKey,
  "notifications": [{
    // Content Settings
    "send_date": "now",
    "ignore_user_timezone": true,
    "content": {
    "en": pushtext
    },
    "platforms": [1, 3, 10, 11],
    // iOS Related
    "ios_category_id": "1",
    "ios_badges": "+1",
    // Android Related
    "android_icon": "icon",
    "android_header":appName, 
    // Chrome related 
    "chrome_title":appName,
    // Safari related
    "safari_title": appName, 
    "safari_action": "Klicka här", 
    "safari_url_args": ["index_webb.html", ""], 
    //"devices":[userdevice],
    "conditions":[["Grupper", "IN", tags]]
  }]
}

};

$.ajax({ type: "POST",

          url: "https://cp.pushwoosh.com/json/1.3/createMessage",
          data: JSON.stringify(data),
          dataType: "json",
          error: function(data){
           myApp.alert("Nothing send!","Appmanager")
            },
          success: function(data){
            myApp.alert("Push is send!","Appmanager")
          }
      });

And here its the "conditions" that is wrong somehow?

If I remove the row with "conditions" then it sends a push to all users, but if I use it, it sends nothing. No errors.

Any input really appreciated, after a couple of days trying, I still don´t know what Im missing :-)

asked 16 Mar '16, 22:57
Manmade's gravatar image

Manmade
113

edited 17 Mar '16, 08:35

Hi!

A condition is always an array of arrays, therefore try this:

"conditions":[["Grupper", "EQ", tags]]

Also, since "Grupper" is a List-type tag, you can only use IN operator with it (see the docs here: http://docs.pushwoosh.com/docs/createmessage#tag-conditions)

permanent link
answered 17 Mar '16, 06:39
Nikolai's gravatar image

Nikolai
3585

I updated with the full code Im using.

(17 Mar '16, 08:36) Manmade Manmade's gravatar image

Hi Nikolai and thanks. I tested but it is not working?

I register from the app/user like this. var tag1="Class 4A" var tag2="Class 4B" pushNotification.setTags({Grupper:[tag1, tag2]}

And I see at pushwoosh that the tag Grupper gets the values in the round chart, it says: Class 4A Grupper:1 (50%)

Is this all I have to do to register a user to get pushes send to "Class 4A"? Or do I have to do something else?

And I have changed to your code "conditions":[["Grupper", "IN", tags]]

But I guess I still miss something?

permanent link
answered 17 Mar '16, 08:27
Manmade's gravatar image

Manmade
113

FINALLY!! It works!! I had to use "conditions":[["Grupper", "IN", [tags]]]

In the pushwoosh docs, in all examples all over the net all examples has been "conditions":["Grupper", "IN", tags] and if the pushwoosh support don´t know the right way, how should anybody?

But finally it works, great!! :-)

permanent link
answered 17 Mar '16, 11:04
Manmade's gravatar image

Manmade
113

My apologies, I completely forgot that for List tags, you must provide the values in an array.

permanent link
answered 17 Mar '16, 11:48
Nikolai's gravatar image

Nikolai
3585

Ok :-) Maybe you know this problem!? when I try to register setTags with "tags": {"Grupper": ["value1", "value2"]} it is not registering it?

(17 Mar '16, 13:54) Manmade Manmade's gravatar image
Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×83
×37
×4

question asked: 16 Mar '16, 22:57

question was seen: 2,005 times

last updated: 17 Mar '16, 13:54