ostinelli / apnotic

A Ruby APNs HTTP/2 gem able to provide instant feedback.
MIT License
480 stars 96 forks source link

Support for hashes as notifications #39

Closed printercu closed 7 years ago

printercu commented 7 years ago

Hi!

WDYT about supporting input hashes in #push and similar methods? I've found that there is new field thread-id in notification body.

If gem would support something like this, it'll be possible to use it without modification after every new field added:

connection.push(
  headers: {
    'apns-id' => apns_id,
    ...
  },
  body: {
    alert: { ... },
    'thread-id' => 1,
  }
)

And Notification can still be supported. It may have #to_h, returning {headers: , body:}, and there will be single check notification = notification.to_h if notification.is_a?(Notification).

If you like the idea, I can prepare PR for it.

UPD. forgot about :token field.

ostinelli commented 7 years ago

Thank you for the input. I don't like this approach, I'd rather ensure that the needed field are properly added to notification.rb.