class RubyPushNotifications::FCM::FCMNotification

Encapsulates a FCM Notification. By default only Required fields are set. (developer.android.com/google/fcm/server-ref.html#send-downstream)

@author Carlos Alonso

Attributes

data[R]
registration_ids[R]

Public Class Methods

new(registration_ids, data) click to toggle source

Initializes the notification

@param [Array]. Array with the receiver's FCM registration ids. @param [Hash]. Payload to send.

# File lib/ruby-push-notifications/fcm/fcm_notification.rb, line 19
def initialize(registration_ids, data)
  @registration_ids = registration_ids
  @data = data
end

Public Instance Methods

as_fcm_json() click to toggle source

@return [String]. The FCM's JSON format for the payload to send.

(https://developer.android.com/google/fcm/server-ref.html#send-downstream)

Credits: github.com/calos0921 - for this url change to FCM std

# File lib/ruby-push-notifications/fcm/fcm_notification.rb, line 31
def as_fcm_json
  JSON.dump(make_payload)
end
make_payload() click to toggle source
# File lib/ruby-push-notifications/fcm/fcm_notification.rb, line 24
def make_payload
  { registration_ids: @registration_ids }.merge(@data)
end