Class: Firebase::Admin::Messaging::Message

Inherits:
Object
  • Object
show all
Defined in:
lib/firebase/admin/messaging/message.rb

Overview

A message that can be sent via Firebase Cloud Messaging.

Contains payload information as well as recipient information. In particular, the message must contain exactly one of token, topic or condition fields.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(data: nil, notification: nil, android: nil, apns: nil, fcm_options: nil, token: nil, topic: nil, condition: nil) ⇒ Message

Parameters:

  • data (Hash<String, String>, nil) (defaults to: nil)

    A hash of data fields (optional). All keys and values must be strings.

  • notification (Notification, nil) (defaults to: nil)

    A Notification (optional).

  • android (AndroidConfig, nil) (defaults to: nil)

    An AndroidConfig (optional).

  • apns (APNSConfig, nil) (defaults to: nil)

    An APNSConfig (optional).

  • fcm_options (FCMOptions, nil) (defaults to: nil)

    An FCMOptions (optional).

  • token (String, nil) (defaults to: nil)

    A registration token of the device to send the message to (optional).

  • topic (String, nil) (defaults to: nil)

    The name of the FCM topic to send the message to (optional). The topic name may contain the ‘/topics/` prefix.

  • condition (String, nil) (defaults to: nil)

    The FCM condition to which the message should be sent (optional).



61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
# File 'lib/firebase/admin/messaging/message.rb', line 61

def initialize(
  data: nil,
  notification: nil,
  android: nil,
  apns: nil,
  fcm_options: nil,
  token: nil,
  topic: nil,
  condition: nil
)
  self.data = data
  self.notification = notification
  self.android = android
  self.apns = apns
  self.fcm_options = fcm_options
  self.token = token
  self.topic = topic
  self.condition = condition
end

Instance Attribute Details

#androidAndroidConfig?

Returns An AndroidConfig (optional).

Returns:



19
20
21
# File 'lib/firebase/admin/messaging/message.rb', line 19

def android
  @android
end

#apnsAPNSConfig?

Returns An APNSConfig (optional).

Returns:



23
24
25
# File 'lib/firebase/admin/messaging/message.rb', line 23

def apns
  @apns
end

#conditionString?

Returns The FCM condition to which the message should be sent (optional).

Returns:

  • (String, nil)

    The FCM condition to which the message should be sent (optional).



40
41
42
# File 'lib/firebase/admin/messaging/message.rb', line 40

def condition
  @condition
end

#dataHash<String, String>?

Returns A hash of data fields (optional). All keys and values must be strings.

Returns:

  • (Hash<String, String>, nil)

    A hash of data fields (optional). All keys and values must be strings.



11
12
13
# File 'lib/firebase/admin/messaging/message.rb', line 11

def data
  @data
end

#fcm_optionsFCMOptions?

Returns An FCMOptions (optional).

Returns:



27
28
29
# File 'lib/firebase/admin/messaging/message.rb', line 27

def fcm_options
  @fcm_options
end

#notificationNotification?

Returns A Notification (optional).

Returns:



15
16
17
# File 'lib/firebase/admin/messaging/message.rb', line 15

def notification
  @notification
end

#tokenString?

Returns Registration token of the device to which the message should be sent (optional).

Returns:

  • (String, nil)

    Registration token of the device to which the message should be sent (optional).



31
32
33
# File 'lib/firebase/admin/messaging/message.rb', line 31

def token
  @token
end

#topicString?

Returns Name of the FCM topic to which the message should be sent (optional). Topic name may contain the ‘/topics/` prefix.

Returns:

  • (String, nil)

    Name of the FCM topic to which the message should be sent (optional). Topic name may contain the ‘/topics/` prefix.



36
37
38
# File 'lib/firebase/admin/messaging/message.rb', line 36

def topic
  @topic
end