On 11 May 2011 08:55, bingo bob <li...@ruby-forum.com> wrote: > I'm using this gem https://github.com/justintv/APNS to send push > notifications to an iPhone app and amazingly it works for single > notifications, such that I can do... > > APNS.send_notification(Device.first.device_token,'test message') > > Works great... > > Now it should be a simple task (as per the docs to send multiple > notifications) > > Gem says like this... > > device_token = '123abc456def' > n1 = [device_token, :aps => { :alert => 'Hello...', :badge => 1, :sound > => 'default' } > n2 = [device_token, :aps => { :alert => '... iPhone!', :badge => 1, > :sound => 'default' }] > APNS.send_notifications([n1, n2])
Have you tried that? It doesn't look like valid ruby to me (even with the missing ] on the end of n1) > > ##### > > for me it's slightly different, I wish to loop through each device in my > db and then send the same message to them all...it's something like this > but it's clearly not quite right... can't get the :aps => thing to work > out. > > I think I need something like this on my Device model, but it's not > right - please help correct it, would greatly appreciate. > > > > def self.push_message_to_all(message) > devices = self.all > notifications = [] > devices.each do |device| > notifications << [device.device_token,message] > end Once you have got the manual example above working the use ruby-debug to break in here and have a look at notifications and see if it is of the same form as if you break into the manual test and look at it there. Colin -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.