前往主控台

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)
  },
  "fcm_options": {
    object (FcmOptions)
  },

  // 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. The key should not be a reserved word ("from", "message_type", or any word starting with "google" or "gcm").

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.

fcm_options

object (FcmOptions)

Input only. Template for FCM SDK feature options to use across all platforms.

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,
  "image": string
}
Fields
title

string

The notification's title.

body

string

The notification's body text.

image

string

Contains the URL of an image that is going to be downloaded on the device and displayed in a notification. JPEG, PNG, BMP have full support across platforms. Animated GIF and video only work on iOS. WebP and HEIF have varying levels of support across platforms and platform versions. Android has 1MB image size limit. Quota usage and implications/costs for hosting image on Firebase Storage: https://firebase.google.com/pricing

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)
  },
  "fcm_options": {
    object (AndroidFcmOptions)
  }
}
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 token 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.

fcm_options

object (AndroidFcmOptions)

Options for features provided by the FCM SDK for Android.

AndroidMessagePriority

Priority of a message to send to Android devices. Note this priority is an FCM concept that controls when the message is delivered. See FCM guides. Additionally, you can determine notification display priority on targeted Android devices using AndroidNotification.NotificationPriority.

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
  ],
  "channel_id": string,
  "ticker": string,
  "sticky": boolean,
  "event_time": string,
  "local_only": boolean,
  "notification_priority": enum (NotificationPriority),
  "default_sound": boolean,
  "default_vibrate_timings": boolean,
  "default_light_settings": boolean,
  "vibrate_timings": [
    string
  ],
  "visibility": enum (Visibility),
  "notification_count": number,
  "light_settings": {
    object (LightSettings)
  },
  "image": 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 spe