dondeng / gcm_on_rails

Gcm on Rails (Google Cloud Messaging for Android on Rails)
MIT License
79 stars 48 forks source link

Notifications - Device association #16

Open vairix-ssierra opened 11 years ago

vairix-ssierra commented 11 years ago

Assuming the notification sender is always the rails application..

I don't understand why the notification only belongs_to :device instead of has_and_belongs_to_many :devices.

Adding this relation will allow to automatically generate the appropriate json to send to GCM in order to send one notification to multiple devices (instead of adding each registration_id "manually").

What do you think? Is there a reason why the notification is associated to only one device?

csgavino commented 11 years ago

Might as well add this here sorry vairix:

Other than having it for relationships sake what is the reason for putting in device?

dondeng commented 11 years ago

@vairix-ssierra you are right, the notification should not be limited to only one device. In fact, in the README, one of the To Do's that are pending is

"- Implement “broadcasting” sending and processing responses to multiple registration id’s within one request. Currently only one message to a single registration id is implemented."

dondeng commented 11 years ago

@csgavino the reason the relationship exists between a notification and a device is because Google requires a notification to contain the registration id's to which that notification will be sent. For the app I am working on, I need to know what notification was sent to which devices, which I am assuming might be the majority of cases too.

vairix-ssierra commented 11 years ago

@dondeng I've just made a pull request that 'solves' this issue.

twigbranch commented 11 years ago

Couple things: 1) I read that there's a 1000 device limit on registration_ids- so the aforementioned pull doesn't take that into account does it?

2) Wondering if like apn_on_rails there should be a group_notification, so instead of storing each notification to each individual device, the notification is stored once for a group of device ids (like apn_on_rails there's a model for device groups and an association to that group)? Then upon sending the group is split into sub-groups of 1000.