Skip to content

Commit

Permalink
Improve the notification example in README
Browse files Browse the repository at this point in the history
  • Loading branch information
collimarco authored Aug 7, 2023
1 parent 4c8aa46 commit 94c7238
Showing 1 changed file with 38 additions and 11 deletions.
49 changes: 38 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,17 +51,40 @@ Pushpad.signature_for current_user.id

```ruby
notification = Pushpad::Notification.new({
# required, the main content of the notification
body: "Hello world!",
title: "Website Name", # optional, defaults to your project name
target_url: "https://example.com", # optional, defaults to your project website
icon_url: "https://example.com/assets/icon.png", # optional, defaults to the project icon
badge_url: "https://example.com/assets/badge.png", # optional, defaults to the project badge
image_url: "https://example.com/assets/image.png", # optional, an image to display in the notification content
ttl: 604800, # optional, drop the notification after this number of seconds if a device is offline
require_interaction: true, # optional, prevent Chrome on desktop from automatically closing the notification after a few seconds
silent: false, # optional, enable this option if you want a mute notification without any sound
urgent: false, # optional, enable this option only for time-sensitive alerts (e.g. incoming phone call)
custom_data: "123", # optional, a string that is passed as an argument to action button callbacks

# optional, the title of the notification (defaults to your project name)
title: "Website Name",

# optional, open this link on notification click (defaults to your project website)
target_url: "https://example.com",

# optional, the icon of the notification (defaults to the project icon)
icon_url: "https://example.com/assets/icon.png",

# optional, the small icon displayed in the status bar (defaults to the project badge)
badge_url: "https://example.com/assets/badge.png",

# optional, an image to display in the notification content
# see https://pushpad.xyz/docs/sending_images
image_url: "https://example.com/assets/image.png",

# optional, drop the notification after this number of seconds if a device is offline
ttl: 604800,

# optional, prevent Chrome on desktop from automatically closing the notification after a few seconds
require_interaction: true,

# optional, enable this option if you want a mute notification without any sound
silent: false,

# optional, enable this option only for time-sensitive alerts (e.g. incoming phone call)
urgent: false,

# optional, a string that is passed as an argument to action button callbacks
custom_data: "123",

# optional, add some action buttons to the notification
# see https://pushpad.xyz/docs/action_buttons
actions: [
Expand All @@ -72,10 +95,14 @@ notification = Pushpad::Notification.new({
action: "myActionName" # optional
}
],
starred: true, # optional, bookmark the notification in the Pushpad dashboard (e.g. to highlight manual notifications)

# optional, bookmark the notification in the Pushpad dashboard (e.g. to highlight manual notifications)
starred: true,

# optional, use this option only if you need to create scheduled notifications (max 5 days)
# see https://pushpad.xyz/docs/schedule_notifications
send_at: Time.utc(2016, 7, 25, 10, 9),

# optional, add the notification to custom categories for stats aggregation
# see https://pushpad.xyz/docs/monitoring
custom_metrics: ['examples', 'another_metric'] # up to 3 metrics per notification
Expand Down

0 comments on commit 94c7238

Please sign in to comment.