adelevie / parse-ruby-client

A simple Ruby client for the parse.com REST API

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Push notifications to multiple channels in an array

vancooler opened this issue · comments

Is there any way to push notifications to multiple channels, for example channels "Fruit" and "Vegetable"? I cannot find anything in the document of this gem.

Thanks in advance.

@vancooler you are correct. That's a bug. In the meantime you can assign an array of channels by doing:

push.channels = ['abc, 'def']

on the push object

@rhymes Thanks for your help. I will try it and update here if it works.

@rhymes It works! Thanks a lot. I do recommend to add it to the documentation in case someone else has similar confusions.

commented

somehow it doesn't work for me. i have

push = @client.push(attributes['data'])
push.channels = ['intern', attributes['channel']]

where attributes['data'] looks like "OZ: Test Titel" and attributes['channel'] looks like "Kultur"
i always get 102: equality needs a value instead of [intern Kultur]

what am i doing wrong?

@torasakura seems to me to be a protocol error.

1 - attributes['data'] has to be an hash in this form

{ :alert => "This is a notification from Parse" }

and not just a string

2 - are you sure attributes['channel'] is a string and not an object that on the console behaves as a string? Can you paste the content?

commented

@rhymes i also tried the channel names hardcoded as push.channels = ['intern', 'Kultur'] but it didn't work either.

commented

ok i narrowed down. it seems that parse has a problem with a channels array in where. this does work

curl -X POST \  Di 10 Nov 2015 17:19:06 CET
    -H "X-Parse-Application-Id: application_id" \
     -H "X-Parse-REST-API-Key: api_key" \
      -H "Content-Type: application/json" \
       -d '{
          "channels": [
              "Giants",
               "Mets"
           ],
          "data": {
               "alert": "The Giants won against the Mets 2-3."
    }
 }' \
https://api.parse.com/1/push

this does not work:

curl -X POST \ Di 10 Nov 2015 17:18:44 CET
   -H "X-Parse-Application-Id: application_id" \
   -H "X-Parse-REST-API-Key: api_key" \
   -H "Content-Type: application/json" \
    -d '{
        "where": {
            "channels": ["Giants", "Mets"],
            "scores": true
        },
       "data": {
        "alert": "The Giants scored a run! The score is now 2-2."
  }
}' \
https://api.parse.com/1/push

and when i read push.rb right, if i use push.channels where is used.

@toothfairy I have the same problem. Did you find a solution?

@odedharth @torasakura I got this issue as well and sent PR fixing it. Please check #213

Closed by #213