Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Notifications - Device association #16

Open
vairix-ssierra opened this issue Nov 29, 2012 · 5 comments
Open

Notifications - Device association #16

vairix-ssierra opened this issue Nov 29, 2012 · 5 comments

Comments

@vairix-ssierra
Copy link

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
Copy link

Might as well add this here sorry vairix:

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

@dondeng
Copy link
Owner

dondeng commented Nov 30, 2012

@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
Copy link
Owner

dondeng commented Nov 30, 2012

@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
Copy link
Author

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

  • added a has_and_belongs_to_many relationship between devices and notifications
  • at the moment of creating the request to send to the GCM, all the registration_ids of the devices associated to the notification being sent are added. There is no need to add them "manually" any more

@twigbranch
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants