REST Resource: projects.messages

Resource: Message

Message to send by Firebase Cloud Messaging Service.

JSON representation
{
  "name": string,
  "data": {
    string: string,
    ...
  },
  "notification": {
    object(Notification)
  },
  "android": {
    object(AndroidConfig)
  },
  "webpush": {
    object(WebpushConfig)
  },
  "apns": {
    object(ApnsConfig)
  },

  // Union field target can be only one of the following:
  "token": string,
  "topic": string,
  "condition": string,
  // End of list of possible types for union field target.
}
Fields
name

string

Output Only. The identifier of the message sent, in the format of projects/*/messages/{message_id}.

data

map (key: string, value: string)

Input only. Arbitrary key/value payload.

An object containing a list of "key": value pairs. Example: { "name": "wrench", "mass": "1.3kg", "count": "3" }.

notification

object(Notification)

Input only. Basic notification template to use across all platforms.

android

object(AndroidConfig)

Input only. Android specific options for messages sent through FCM connection server.

webpush

object(WebpushConfig)

Input only. Webpush protocol options.

apns

object(ApnsConfig)

Input only. Apple Push Notification Service specific options.

Union field target. Required. Input only. Target to send a message to. target can be only one of the following:
token

string

Registration token to send a message to.

topic

string

Topic name to send a message to, e.g. "weather". Note: "/topics/" prefix should not be provided.

condition

string

Condition to send a message to, e.g. "'foo' in topics && 'bar' in topics".

Notification

Basic notification template to use across all platforms.

JSON representation
{
  "title": string,
  "body": string,
}
Fields
title

string

The notification's title.

body

string

The notification's body text.

AndroidConfig

Android specific options for messages sent through FCM connection server.

JSON representation
{
  "collapse_key": string,
  "priority": enum(AndroidMessagePriority),
  "ttl": string,
  "restricted_package_name": string,
  "data": {
    string: string,
    ...
  },
  "notification": {
    object(AndroidNotification)
  },
}
Fields
collapse_key

string

An identifier of a group of messages that can be collapsed, so that only the last message gets sent when delivery can be resumed. A maximum of 4 different collapse keys is allowed at any given time.

priority

enum(AndroidMessagePriority)

Message priority. Can take "normal" and "high" values. For more information, see Setting the priority of a message.

ttl

string (Duration format)

How long (in seconds) the message should be kept in FCM storage if the device is offline. The maximum time to live supported is 4 weeks, and the default value is 4 weeks if not set. Set it to 0 if want to send the message immediately. In JSON format, the Duration type is encoded as a string rather than an object, where the string ends in the suffix "s" (indicating seconds) and is preceded by the number of seconds, with nanoseconds expressed as fractional seconds. For example, 3 seconds with 0 nanoseconds should be encoded in JSON format as "3s", while 3 seconds and 1 nanosecond should be expressed in JSON format as "3.000000001s". The ttl will be rounded down to the nearest second.

A duration in seconds with up to nine fractional digits, terminated by 's'. Example: "3.5s".

restricted_package_name

string

Package name of the application where the registration tokens must match in order to receive the message.

data

map (key: string, value: string)

Arbitrary key/value payload. If present, it will override google.firebase.fcm.v1.Message.data.

An object containing a list of "key": value pairs. Example: { "name": "wrench", "mass": "1.3kg", "count": "3" }.

notification

object(AndroidNotification)

Notification to send to android devices.

AndroidMessagePriority

Priority of a message to send to Android devices.

Enums
NORMAL Default priority for data messages. Normal priority messages won't open network connections on a sleeping device, and their delivery may be delayed to conserve the battery. For less time-sensitive messages, such as notifications of new email or other data to sync, choose normal delivery priority.
HIGH Default priority for notification messages. FCM attempts to deliver high priority messages immediately, allowing the FCM service to wake a sleeping device when possible and open a network connection to your app server. Apps with instant messaging, chat, or voice call alerts, for example, generally need to open a network connection and make sure FCM delivers the message to the device without delay. Set high priority if the message is time-critical and requires the user's immediate interaction, but beware that setting your messages to high priority contributes more to battery drain compared with normal priority messages.

AndroidNotification

Notification to send to android devices.

JSON representation
{
  "title": string,
  "body": string,
  "icon": string,
  "color": string,
  "sound": string,
  "tag": string,
  "click_action": string,
  "body_loc_key": string,
  "body_loc_args": [
    string
  ],
  "title_loc_key": string,
  "title_loc_args": [
    string
  ],
}
Fields
title

string

The notification's title. If present, it will override google.firebase.fcm.v1.Notification.title.

body

string

The notification's body text. If present, it will override google.firebase.fcm.v1.Notification.body.

icon

string

The notification's icon. Sets the notification icon to myicon for drawable resource myicon. If you don't send this key in the request, FCM displays the launcher icon specified in your app manifest.

color

string

The notification's icon color, expressed in #rrggbb format.

sound

string

The sound to play when the device receives the notification. Supports "default" or the filename of a sound resource bundled in the app. Sound files must reside in /res/raw/.

tag

string

Identifier used to replace existing notifications in the notification drawer. If not specified, each request creates a new notification. If specified and a notification with the same tag is already being shown, the new notification replaces the existing one in the notification drawer.

click_action

string

The 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.

body_loc_key

string

The key to the body string in the app's string resources to use to localize the body text to the user's current localization. See String Resources for more information.

body_loc_args[]

string

Variable string values to be used in place of the format specifiers in body_loc_key to use to localize the body text to the user's current localization. See Formatting and Styling for more information.

title_loc_key

string

The key to the title string in the app's string resources to use to localize the title text to the user's current localization. See String Resources for more information.

title_loc_args[]

string

Variable string values to be used in place of the format specifiers in title_loc_key to use to localize the title text to the user's current localization. See Formatting and Styling for more information.

WebpushConfig

Webpush protocol options.

JSON representation
{
  "headers": {
    string: string,
    ...
  },
  "data": {
    string: string,
    ...
  },
  "notification": {
    object
  },
}
Fields
headers

map (key: string, value: string)

HTTP headers defined in webpush protocol. Refer to Webpush protocol for supported headers, e.g. "TTL": "15".

An object containing a list of "key": value pairs. Example: { "name": "wrench", "mass": "1.3kg", "count": "3" }.

data

map (key: string, value: string)

Arbitrary key/value payload. If present, it will override google.firebase.fcm.v1.Message.data.

An object containing a list of "key": value pairs. Example: { "name": "wrench", "mass": "1.3kg", "count": "3" }.

notification

object (Struct format)

Web Notification options as a JSON object. Supports Notification instance properties as defined in Web Notification API. If present, "title" and "body" fields override google.firebase.fcm.v1.Notification.title and google.firebase.fcm.v1.Notification.body.

ApnsConfig

Apple Push Notification Service specific options.

JSON representation
{
  "headers": {
    string: string,
    ...
  },
  "payload": {
    object
  },
}
Fields
headers

map (key: string, value: string)

HTTP request headers defined in Apple Push Notification Service. Refer to APNs request headers for supported headers, e.g. "apns-priority": "10".

An object containing a list of "key": value pairs. Example: { "name": "wrench", "mass": "1.3kg", "count": "3" }.

payload

object (Struct format)

APNs payload as a JSON object, including both aps dictionary and custom payload. See Payload Key Reference. If present, it overrides google.firebase.fcm.v1.Notification.title and google.firebase.fcm.v1.Notification.body.

Methods

send

Send a message to specified target (a registration token, topic or condition).

Send feedback about...

Need help? Visit our support page.