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

Scopes

You will need authorization for at least one of the following scopes to make a valid call:

  • https://www.googleapis.com/auth/cloud-platform
  • https://www.googleapis.com/auth/firebase.messaging

If unset, the scope for this method defaults to https://www.googleapis.com/auth/cloud-platform. You can set the scope for this method like this: fcm1 --scope <scope> projects messages-send ...

Required Scalar Argument

  • <parent> (string)
    • Required. It contains the Firebase project id (i.e. the unique identifier for your Firebase project), in the format of projects/{project_id}. For legacy support, the numeric project number with no padding is also supported in the format of projects/{project_number}.

Required Request Value

The request value is a data-structure with various fields. Each field may be a simple scalar or another data-structure. In the latter case it is advised to set the field-cursor to the data-structure's field to specify values more concisely.

For example, a structure like this:

SendMessageRequest:
  message:
    android:
      collapse-key: string
      data: { string: string }
      direct-boot-ok: boolean
      fcm-options:
        analytics-label: string
      notification:
        body: string
        body-loc-args: [string]
        body-loc-key: string
        bypass-proxy-notification: boolean
        channel-id: string
        click-action: string
        color: string
        default-light-settings: boolean
        default-sound: boolean
        default-vibrate-timings: boolean
        event-time: string
        icon: string
        image: string
        light-settings:
          color:
            alpha: number
            blue: number
            green: number
            red: number
          light-off-duration: string
          light-on-duration: string
        local-only: boolean
        notification-count: integer
        notification-priority: string
        proxy: string
        sound: string
        sticky: boolean
        tag: string
        ticker: string
        title: string
        title-loc-args: [string]
        title-loc-key: string
        vibrate-timings: [string]
        visibility: string
      priority: string
      restricted-package-name: string
      ttl: string
    apns:
      fcm-options:
        analytics-label: string
        image: string
      headers: { string: string }
    condition: string
    data: { string: string }
    fcm-options:
      analytics-label: string
    name: string
    notification:
      body: string
      image: string
      title: string
    token: string
    topic: string
    webpush:
      data: { string: string }
      fcm-options:
        analytics-label: string
        link: string
      headers: { string: string }
  validate-only: boolean

can be set completely with the following arguments which are assumed to be executed in the given order. Note how the cursor position is adjusted to the respective structures, allowing simple field names to be used most of the time.

  • -r .message.android collapse-key=et
    • 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.
  • data=key=magna
    • Arbitrary key/value payload. If present, it will override google.firebase.fcm.v1.Message.data.
    • the value will be associated with the given key
  • direct-boot-ok=true
    • If set to true, messages will be allowed to be delivered to the app while the device is in direct boot mode. See Support Direct Boot mode.
  • fcm-options analytics-label=voluptua.

    • Label associated with the message's analytics data.
  • ..notification body=at

    • The notification's body text. If present, it will override google.firebase.fcm.v1.Notification.body.
  • body-loc-args=sanctus
    • 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.
    • Each invocation of this argument appends the given value to the array.
  • body-loc-key=sed
    • 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.
  • bypass-proxy-notification=true
    • If set, display notifications delivered to the device will be handled by the app instead of the proxy.
  • channel-id=amet.
    • The notification's channel id (new in Android O). The app must create a channel with this channel ID before any notification with this channel ID is 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.
  • click-action=duo
    • 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.
  • color=ipsum
    • The notification's icon color, expressed in #rrggbb format.
  • default-light-settings=true
    • 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.
  • default-sound=true
    • If set to true, use the Android framework's default sound for the notification. Default values are specified in config.xml.
  • default-vibrate-timings=false
    • 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.
  • event-time=dolor
    • Set the time that the event in the notification occurred. Notifications in the panel are sorted by this time. A point in time is represented using protobuf.Timestamp.
  • icon=ea
    • 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.
  • image=ipsum
    • Contains the URL of an image that is going to be displayed in a notification. If present, it will override google.firebase.fcm.v1.Notification.image.
  • light-settings.color alpha=0.1092883976212714
    • The fraction of this color that should be applied to the pixel. That is, the final pixel color is defined by the equation: pixel color = alpha * (this color) + (1.0 - alpha) * (background color) This means that a value of 1.0 corresponds to a solid color, whereas a value of 0.0 corresponds to a completely transparent color. This uses a wrapper message rather than a simple float scalar so that it is possible to distinguish between a default value and the value being unset. If omitted, this color object is rendered as a solid color (as if the alpha value had been explicitly given a value of 1.0).
  • blue=0.8204376297831348
    • The amount of blue in the color as a value in the interval [0, 1].
  • green=0.39873905405496446
    • The amount of green in the color as a value in the interval [0, 1].
  • red=0.06534313042009643

    • The amount of red in the color as a value in the interval [0, 1].
  • .. light-off-duration=gubergren

    • Required. Along with light_on_duration, define the blink rate of LED flashes. Resolution defined by proto.Duration
  • light-on-duration=rebum.

    • Required. Along with light_off_duration, define the blink rate of LED flashes. Resolution defined by proto.Duration
  • .. local-only=true

    • Set 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. See Wear OS guides
  • notification-count=51
    • Sets the number of items this notification represents. May be displayed as a badge count for launchers that support badging.See Notification Badge. 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.
  • notification-priority=ipsum
    • Set the relative priority for this notification. Priority is an indication of how much of the user's attention should be consumed by this notification. Low-priority notifications may be hidden from the user in certain situations, while the user might be interrupted for a higher-priority notification. The effect of setting the same priorities may differ slightly on different platforms. 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.
  • proxy=est
    • Setting to control when a notification may be proxied.
  • sound=gubergren
    • 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/.
  • sticky=false
    • 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.
  • tag=lorem
    • 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.
  • ticker=eos
    • 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.
  • title=labore
    • The notification's title. If present, it will override google.firebase.fcm.v1.Notification.title.
  • title-loc-args=sed
    • 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.
    • Each invocation of this argument appends the given value to the array.
  • title-loc-key=duo
    • 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.
  • vibrate-timings=sed
    • Set the vibration pattern to use. Pass in an array of protobuf.Duration to turn on or off the vibrator. 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.
    • Each invocation of this argument appends the given value to the array.
  • visibility=no

  • .. priority=stet

  • restricted-package-name=kasd
    • Package name of the application where the registration token must match in order to receive the message.
  • ttl=et

    • 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.
  • ..apns.fcm-options analytics-label=sed

    • Label associated with the message's analytics data.
  • image=et

    • Contains the URL of an image that is going to be displayed in a notification. If present, it will override google.firebase.fcm.v1.Notification.image.
  • .. headers=key=et

    • HTTP request headers defined in Apple Push Notification Service. Refer to APNs request headers for supported headers such as apns-expiration and apns-priority. The backend sets a default value for apns-expiration of 30 days and a default value for apns-priority of 10 if not explicitly set.
    • the value will be associated with the given key
  • .. condition=vero

    • Condition to send a message to, e.g. "'foo' in topics && 'bar' in topics".
  • data=key=erat
    • Input only. Arbitrary key/value payload, which must be UTF-8 encoded. The key should not be a reserved word ("from", "message_type", or any word starting with "google" or "gcm"). When sending payloads containing only data fields to iOS devices, only normal priority (&#34;apns-priority&#34;: &#34;5&#34;) is allowed in ApnsConfig.
    • the value will be associated with the given key
  • fcm-options analytics-label=sed

    • Label associated with the message's analytics data.
  • .. name=duo

    • Output Only. The identifier of the message sent, in the format of projects/*/messages/{message_id}.
  • notification body=dolore
    • The notification's body text.
  • image=et
    • 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
  • title=voluptua.

    • The notification's title.
  • .. token=amet.

    • Registration token to send a message to.
  • topic=consetetur
    • Topic name to send a message to, e.g. "weather". Note: "/topics/" prefix should not be provided.
  • webpush data=key=diam
    • Arbitrary key/value payload. If present, it will override google.firebase.fcm.v1.Message.data.
    • the value will be associated with the given key
  • fcm-options analytics-label=dolor
    • Label associated with the message's analytics data.
  • link=et

    • The link to open when the user clicks on the notification. For all URL values, HTTPS is required.
  • .. headers=key=et

    • HTTP headers defined in webpush protocol. Refer to Webpush protocol for supported headers, e.g. "TTL": "15".
    • the value will be associated with the given key
  • ... validate-only=false

    • Flag for testing the request without actually delivering the message.

About Cursors

The cursor position is key to comfortably set complex nested structures. The following rules apply:

  • The cursor position is always set relative to the current one, unless the field name starts with the . character. Fields can be nested such as in -r f.s.o .
  • The cursor position is set relative to the top-level structure if it starts with ., e.g. -r .s.s
  • You can also set nested fields without setting the cursor explicitly. For example, to set a value relative to the current cursor position, you would specify -r struct.sub_struct=bar.
  • You can move the cursor one level up by using ... Each additional . moves it up one additional level. E.g. ... would go three levels up.

Optional Output Flags

The method's return value a JSON encoded structure, which will be written to standard output by default.

  • -o out
    • out specifies the destination to which to write the server's result to. It will be a JSON-encoded structure. The destination may be - to indicate standard output, or a filepath that is to contain the received bytes. If unset, it defaults to standard output.

Optional General Properties

The following properties can configure any call, and are not specific to this method.

  • -p $-xgafv=string

    • V1 error format.
  • -p access-token=string

    • OAuth access token.
  • -p alt=string

    • Data format for response.
  • -p callback=string

    • JSONP
  • -p fields=string

    • Selector specifying which fields to include in a partial response.
  • -p key=string

    • API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
  • -p oauth-token=string

    • OAuth 2.0 token for the current user.
  • -p pretty-print=boolean

    • Returns response with indentations and line breaks.
  • -p quota-user=string

    • Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
  • -p upload-type=string

    • Legacy upload protocol for media (e.g. "media", "multipart").
  • -p upload-protocol=string

    • Upload protocol for media (e.g. "raw", "multipart").