Open vairix-ssierra opened 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
?
@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."
@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.
@dondeng I've just made a pull request that 'solves' this issue.
has_and_belongs_to_many
relationship between devices and notificationsregistration_ids
of the devices associated to the notification being sent are added. There is no need to add them "manually" any moreCouple 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.
Assuming the notification sender is always the rails application..
I don't understand why the notification only
belongs_to :device
instead ofhas_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?