calonso / rails-push-notifications

Rails iOS, Android and Windows Phone Push Notifications made easy!!
https://rubygems.org/gems/rails-push-notifications
MIT License
138 stars 44 forks source link

Send additional data using this gem #21

Open hugoh59 opened 6 years ago

hugoh59 commented 6 years ago

How can you send additonal data like these:

{
  "to": "<token>",
  "time_to_live": 86400,
  "collapse_key": "new_message",
  "delay_while_idle": false,
  "notification": {
    "title": "title",
    "body": "this is a noisy test",
    "tag": "new_message",
    "icon": "new_message",
    "color": "#18d821",
    "sound": "default"
  }
}

using your gem? Thanks

calonso commented 6 years ago

Hi @hugoh1995 This plugin uses ruby-push-notifications gem to actually push the notifications. You can see an example here of how APNS notifications are created. You can add anything you want to that hash as long as it follows the rules. Hope it helps.

hugoh59 commented 6 years ago

@calonso thanks for getting back! I'm looking for an example for Android actually, are there any?

calonso commented 6 years ago

Sure, you have examples for all supported platforms. Hope it helps!