Feature: Push notifications for Android (#5792)

* Feature: Push notifications for Android

Notification config for desktop and mobile are merged.

Desktop notifications stay as they are for desktop views.

If mobile mode, push notifications are enabled.

Added push notification subscriptions in their own table, rather than through
custom fields.

Notification banner prompts appear for both mobile and desktop when enabled.
This commit is contained in:
Jeff Wong
2018-05-04 15:31:48 -07:00
committed by GitHub
parent 4c9f6e192f
commit 91b31860a1
34 changed files with 603 additions and 33 deletions

View File

@ -0,0 +1,21 @@
class PushNotificationController < ApplicationController
layout false
before_action :ensure_logged_in
skip_before_action :preload_json
def subscribe
PushNotificationPusher.subscribe(current_user, push_params, params[:send_confirmation])
render json: success_json
end
def unsubscribe
PushNotificationPusher.unsubscribe(current_user, push_params)
render json: success_json
end
private
def push_params
params.require(:subscription).permit(:endpoint, keys: [:p256dh, :auth])
end
end