Run the following commands to add Noticed-WebPush to your Gemfile and install the engine.
bundle add noticed-web_push --github jbennett/noticed-web_push
rails g noticed:web_push:install
rails noticed_web_push:install:migrations
rails db:migrate
Generate and save encryption keys. Do this for all your environments.
rails g noticed:web_push:vapid_keys
rails credentials:edit
Add the web_push
delivery method to your existing notifications
class NewPostNotification < Noticed::Base
deliver_by :database
deliver_by :web_push, data_method: :web_push_data
param :post
def post
params[:post]
end
def web_push_data
{
title: "New post: #{post.title}",
body: post.content.truncate(40),
url: post_url(post),
}
end
end
add details about service_worker paths etc and how the manifest etc are special
The gem is available as open source under the terms of the MIT License.