adelevie / parse-ruby-client

A simple Ruby client for the parse.com REST API
MIT License
415 stars 137 forks source link

Push notifications to multiple channels in an array #190

Closed vancooler closed 7 years ago

vancooler commented 9 years ago

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.

rhymes commented 9 years ago

@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

vancooler commented 9 years ago

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

vancooler commented 9 years ago

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

torasakura commented 8 years ago

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?

rhymes commented 8 years ago

@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?

torasakura commented 8 years ago

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

torasakura commented 8 years ago

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.

odedharth commented 8 years ago

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

nashby commented 7 years ago

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

rhymes commented 7 years ago

Closed by #213