Class: RailsPushNotifications::BaseApp

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
lib/rails-push-notifications/apps/base_app.rb

Overview

Abstract. This class is the base of all application entity type.

Author:

  • Carlos Alonso

Direct Known Subclasses

APNSApp, FCMApp, GCMApp, MPNSApp

Instance Method Summary collapse

Instance Method Details

#push_notificationsObject

This method will find all notifications owned by this app and push them.



18
19
20
21
22
23
24
25
26
27
28
# File 'lib/rails-push-notifications/apps/base_app.rb', line 18

def push_notifications
  pending = find_pending
  to_send = pending.map do |notification|
    notification_type.new notification.destinations, notification.data
  end
  pusher = build_pusher
  pusher.push to_send
  pending.each_with_index do |p, i|
    p.update_attributes! results: to_send[i].results
  end
end