Class: Firebase::Admin::Messaging::AndroidNotification

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

Overview

Android-specific notification options that can be included in an AndroidConfig.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(title: nil, body: nil, icon: nil, color: nil, sound: nil, tag: nil, image: nil, click_action: nil, body_loc_key: nil, body_loc_args: nil, title_loc_key: nil, title_loc_args: nil, channel_id: nil, ticker: nil, sticky: nil, event_time: nil, local_only: nil, priority: nil, vibrate_timings: nil, default_vibrate_timings: nil, default_sound: nil, light_settings: nil, default_light_settings: nil, visibility: nil, notification_count: nil) ⇒ AndroidNotification

Initializes an AndroidNotification

Parameters:

  • title (String, nil) (defaults to: nil)
  • body (String, nil) (defaults to: nil)
  • icon (String, nil) (defaults to: nil)
  • color (String, nil) (defaults to: nil)
  • sound (String, nil) (defaults to: nil)
  • tag (String, nil) (defaults to: nil)
  • image (String, nil) (defaults to: nil)
  • click_action (String, nil) (defaults to: nil)
  • body_loc_key (String, nil) (defaults to: nil)
  • body_loc_args (Array<String>, nil) (defaults to: nil)
  • title_loc_key (String, nil) (defaults to: nil)
  • title_loc_args (Array<String>, nil) (defaults to: nil)
  • channel_id (String, nil) (defaults to: nil)
  • ticker (String, nil) (defaults to: nil)
  • sticky (Boolean, nil) (defaults to: nil)
  • event_time (Time, nil) (defaults to: nil)
  • local_only (Boolean, nil) (defaults to: nil)
  • priority (String, nil) (defaults to: nil)
  • vibrate_timings (Array<Numeric>, nil) (defaults to: nil)
  • default_vibrate_timings (Boolean, nil) (defaults to: nil)
  • default_sound (Boolean, nil) (defaults to: nil)
  • light_settings (LightSettings, nil) (defaults to: nil)
  • default_light_settings (Boolean, nil) (defaults to: nil)
  • visibility (String, nil) (defaults to: nil)
  • notification_count (Integer, nil) (defaults to: nil)


165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
# File 'lib/firebase/admin/messaging/android_notification.rb', line 165

def initialize(
  title: nil,
  body: nil,
  icon: nil,
  color: nil,
  sound: nil,
  tag: nil,
  image: nil,
  click_action: nil,
  body_loc_key: nil,
  body_loc_args: nil,
  title_loc_key: nil,
  title_loc_args: nil,
  channel_id: nil,
  ticker: nil,
  sticky: nil,
  event_time: nil,
  local_only: nil,
  priority: nil,
  vibrate_timings: nil,
  default_vibrate_timings: nil,
  default_sound: nil,
  light_settings: nil,
  default_light_settings: nil,
  visibility: nil,
  notification_count: nil
)
  self.title = title
  self.body = body
  self.icon = icon
  self.color = color
  self.sound = sound
  self.tag = tag
  self.image = image
  self.click_action = click_action
  self.body_loc_key = body_loc_key
  self.body_loc_args = body_loc_args
  self.title_loc_key = title_loc_key
  self.title_loc_args = title_loc_args
  self.channel_id = channel_id
  self.ticker = ticker
  self.sticky = sticky
  self.event_time = event_time
  self.local_only = local_only
  self.priority = priority
  self.vibrate_timings = vibrate_timings
  self.default_vibrate_timings = default_vibrate_timings
  self.default_sound = default_sound
  self.light_settings = light_settings
  self.default_light_settings = default_light_settings
  self.visibility = visibility
  self.notification_count = notification_count
end

Instance Attribute Details

#bodyString?

Returns Body of the Android notification. When provided, overrides the body set via Notification.

Returns:

  • (String, nil)

    Body of the Android notification. When provided, overrides the body set via Notification.



12
13
14
# File 'lib/firebase/admin/messaging/android_notification.rb', line 12

def body
  @body
end

#body_loc_argsArray<String>?

Returns An array of resource keys that will be used in place of the format specifiers in #body_loc_key.

Returns:

  • (Array<String>, nil)

    An array of resource keys that will be used in place of the format specifiers in #body_loc_key.



46
47
48
# File 'lib/firebase/admin/messaging/android_notification.rb', line 46

def body_loc_args
  @body_loc_args
end

#body_loc_keyString?

Returns Key of the body string in the app’s string resource to use to localize the body text.

Returns:

  • (String, nil)

    Key of the body string in the app’s string resource to use to localize the body text.



42
43
44
# File 'lib/firebase/admin/messaging/android_notification.rb', line 42

def body_loc_key
  @body_loc_key
end

#channel_idString?

Returns The Android notification channel id (new in Android O). The app must create a channel with this channel id before any notification with this channel id can be received. If you don’t send this channel id in the request, or if the channel id provided has not yet been created by the app, FCM uses the channel id specified in the app manifest.

Returns:

  • (String, nil)

    The Android notification channel id (new in Android O). The app must create a channel with this channel id before any notification with this channel id can be received. If you don’t send this channel id in the request, or if the channel id provided has not yet been created by the app, FCM uses the channel id specified in the app manifest.



61
62
63
# File 'lib/firebase/admin/messaging/android_notification.rb', line 61

def channel_id
  @channel_id
end

#click_actionString?

Returns Action associated with a user click on the notification. If specified, an activity with a matching Intent Filter is launched when a user clicks on the notification.

Returns:

  • (String, nil)

    Action associated with a user click on the notification. If specified, an activity with a matching Intent Filter is launched when a user clicks on the notification.



38
39
40
# File 'lib/firebase/admin/messaging/android_notification.rb', line 38

def click_action
  @click_action
end

#colorString?

Returns Notification icon color in ‘#rrggbb` format.

Returns:

  • (String, nil)

    Notification icon color in ‘#rrggbb` format.



20
21
22
# File 'lib/firebase/admin/messaging/android_notification.rb', line 20

def color
  @color
end

#default_light_settingsBoolean?

Returns If set to ‘true`, use the Android framework’s default LED light settings for the notification. Default values are specified in ‘config.xml`. If `default_light_settings` is set to `true` and `light_settings` is also set, the user-specified `light_settings` is used instead of the default value.

Returns:

  • (Boolean, nil)

    If set to ‘true`, use the Android framework’s default LED light settings for the notification. Default values are specified in ‘config.xml`. If `default_light_settings` is set to `true` and `light_settings` is also set, the user-specified `light_settings` is used instead of the default value.

See Also:



122
123
124
# File 'lib/firebase/admin/messaging/android_notification.rb', line 122

def default_light_settings
  @default_light_settings
end

#default_soundBoolean?

Returns If set to ‘true`, use the Android framework’s default sound for the notification. Default values are specified in ‘config.xml`.

Returns:

  • (Boolean, nil)

    If set to ‘true`, use the Android framework’s default sound for the notification. Default values are specified in ‘config.xml`.

See Also:



110
111
112
# File 'lib/firebase/admin/messaging/android_notification.rb', line 110

def default_sound
  @default_sound
end

#default_vibrate_timingsBoolean?

Returns If set to ‘true`, use the Android framework’s default vibrate pattern for the notification. Default values are specified in ‘config.xml`. If `default_vibrate_timings` is set to `true` and `vibrate_timings` is also set, the default value is used instead of the user-specified `vibrate_timings`.

Returns:

  • (Boolean, nil)

    If set to ‘true`, use the Android framework’s default vibrate pattern for the notification. Default values are specified in ‘config.xml`. If `default_vibrate_timings` is set to `true` and `vibrate_timings` is also set, the default value is used instead of the user-specified `vibrate_timings`.

See Also:



104
105
106
# File 'lib/firebase/admin/messaging/android_notification.rb', line 104

def default_vibrate_timings
  @default_vibrate_timings
end

#event_timeTime?

Returns For notifications that inform users about events with an absolute time reference, sets the time that the event in the notification occurred. Notifications in the panel are sorted by this time.

Returns:

  • (Time, nil)

    For notifications that inform users about events with an absolute time reference, sets the time that the event in the notification occurred. Notifications in the panel are sorted by this time.



76
77
78
# File 'lib/firebase/admin/messaging/android_notification.rb', line 76

def event_time
  @event_time
end

#iconString?

Returns Icon resource for the Android notification.

Returns:

  • (String, nil)

    Icon resource for the Android notification.



16
17
18
# File 'lib/firebase/admin/messaging/android_notification.rb', line 16

def icon
  @icon
end

#imageString?

Returns URL of an image to be displayed in the notification.

Returns:

  • (String, nil)

    URL of an image to be displayed in the notification.



33
34
35
# File 'lib/firebase/admin/messaging/android_notification.rb', line 33

def image
  @image
end

#light_settingsLightSettings?

Returns Settings to control the notification’s LED blinking rate and color if LED is available on the device. The total blinking time is controlled by the OS.

Returns:

  • (LightSettings, nil)

    Settings to control the notification’s LED blinking rate and color if LED is available on the device. The total blinking time is controlled by the OS.



115
116
117
# File 'lib/firebase/admin/messaging/android_notification.rb', line 115

def light_settings
  @light_settings
end

#local_onlyBoolean?

Returns Sets whether or not this notification is relevant only to the current device. Some notifications can be bridged to other devices for remote display, such as a Wear OS watch. This hint can be set to recommend this notification not be bridged.

Returns:

  • (Boolean, nil)

    Sets whether or not this notification is relevant only to the current device. Some notifications can be bridged to other devices for remote display, such as a Wear OS watch. This hint can be set to recommend this notification not be bridged.



82
83
84
# File 'lib/firebase/admin/messaging/android_notification.rb', line 82

def local_only
  @local_only
end

#notification_countInteger?

Returns Sets the number of items this notification represents. May be displayed as a badge count for Launchers that support badging. For example, this might be useful if you’re using just one notification to represent multiple new messages but you want the count here to represent the number of total new messages. If zero or unspecified, systems that support badging use the default, which is to increment a number displayed on the long-press menu each time a new notification arrives.

Returns:

  • (Integer, nil)

    Sets the number of items this notification represents. May be displayed as a badge count for Launchers that support badging. For example, this might be useful if you’re using just one notification to represent multiple new messages but you want the count here to represent the number of total new messages. If zero or unspecified, systems that support badging use the default, which is to increment a number displayed on the long-press menu each time a new notification arrives.

See Also:



136
137
138
# File 'lib/firebase/admin/messaging/android_notification.rb', line 136

def notification_count
  @notification_count
end

#priorityString?

Returns Sets the relative priority for this notification. Low-priority notifications may be hidden from the user in certain situations. Note this priority differs from ‘AndroidMessagePriority`. This priority is processed by the client after the message has been delivered. Whereas `AndroidMessagePriority` is an FCM concept that controls when the message is delivered.

Returns:

  • (String, nil)

    Sets the relative priority for this notification. Low-priority notifications may be hidden from the user in certain situations. Note this priority differs from ‘AndroidMessagePriority`. This priority is processed by the client after the message has been delivered. Whereas `AndroidMessagePriority` is an FCM concept that controls when the message is delivered.



89
90
91
# File 'lib/firebase/admin/messaging/android_notification.rb', line 89

def priority
  @priority
end

#soundString?

Returns File name of the sound to be played when the device receives the notification.

Returns:

  • (String, nil)

    File name of the sound to be played when the device receives the notification.



24
25
26
# File 'lib/firebase/admin/messaging/android_notification.rb', line 24

def sound
  @sound
end

#stickyBoolean?

Returns When set to ‘false` or unset, the notification is automatically dismissed when the user clicks it in the panel. When set to `true`, the notification persists even when the user clicks it.

Returns:

  • (Boolean, nil)

    When set to ‘false` or unset, the notification is automatically dismissed when the user clicks it in the panel. When set to `true`, the notification persists even when the user clicks it.



71
72
73
# File 'lib/firebase/admin/messaging/android_notification.rb', line 71

def sticky
  @sticky
end

#tagString?

Returns Notification tag. This is an identifier used to replace existing notifications in the notification drawer. If not specified, each request creates a new notification.

Returns:

  • (String, nil)

    Notification tag. This is an identifier used to replace existing notifications in the notification drawer. If not specified, each request creates a new notification.



29
30
31
# File 'lib/firebase/admin/messaging/android_notification.rb', line 29

def tag
  @tag
end

#tickerString?

Returns Sets the “ticker” text, which is sent to accessibility services. Prior to API level 21 (Lollipop), sets the text that is displayed in the status bar when the notification first arrives.

Returns:

  • (String, nil)

    Sets the “ticker” text, which is sent to accessibility services. Prior to API level 21 (Lollipop), sets the text that is displayed in the status bar when the notification first arrives.



66
67
68
# File 'lib/firebase/admin/messaging/android_notification.rb', line 66

def ticker
  @ticker
end

#titleString?

Returns Title of the Android notification. When provided, overrides the title set via Notification.

Returns:

  • (String, nil)

    Title of the Android notification. When provided, overrides the title set via Notification.



8
9
10
# File 'lib/firebase/admin/messaging/android_notification.rb', line 8

def title
  @title
end

#title_loc_argsArray<String>?

Returns An array of resource keys that will be used in place of the format specifiers in #title_loc_key.

Returns:

  • (Array<String>, nil)

    An array of resource keys that will be used in place of the format specifiers in #title_loc_key.



54
55
56
# File 'lib/firebase/admin/messaging/android_notification.rb', line 54

def title_loc_args
  @title_loc_args
end

#title_loc_keyString?

Returns Key of the title string in the app’s string resource to use to localize the title text.

Returns:

  • (String, nil)

    Key of the title string in the app’s string resource to use to localize the title text.



50
51
52
# File 'lib/firebase/admin/messaging/android_notification.rb', line 50

def title_loc_key
  @title_loc_key
end

#vibrate_timingsArray<Numeric>?

Returns Sets the vibration pattern to use. Pass in an array of numeric durations to turn the vibrator on or off. The first value indicates the duration to wait before turning the vibrator on. The next value indicates the duration to keep the vibrator on. Subsequent values alternate between duration to turn the vibrator off and to turn the vibrator on. If ‘vibrate_timings` is set and `default_vibrate_timings` is set to `true`, the default value is used instead of the user-specified `vibrate_timings`.

Returns:

  • (Array<Numeric>, nil)

    Sets the vibration pattern to use. Pass in an array of numeric durations to turn the vibrator on or off. The first value indicates the duration to wait before turning the vibrator on. The next value indicates the duration to keep the vibrator on. Subsequent values alternate between duration to turn the vibrator off and to turn the vibrator on. If ‘vibrate_timings` is set and `default_vibrate_timings` is set to `true`, the default value is used instead of the user-specified `vibrate_timings`.



97
98
99
# File 'lib/firebase/admin/messaging/android_notification.rb', line 97

def vibrate_timings
  @vibrate_timings
end

#visibilityString?

Returns Sets the visibility of the notification. Must be either ‘private`, `public`, or `secret`. If unspecified, defaults to `private`.

Returns:

  • (String, nil)

    Sets the visibility of the notification. Must be either ‘private`, `public`, or `secret`. If unspecified, defaults to `private`.



127
128
129
# File 'lib/firebase/admin/messaging/android_notification.rb', line 127

def visibility
  @visibility
end