send method

Future<Message> send(
  1. SendMessageRequest request,
  2. String parent, {
  3. String? $fields,
})

Send a message to specified target (a [Firebase Installation ID (FID)](/docs/cloud-messaging/android/get-started#access-firebase-installation-id), registration token, topic, or condition).

If duplicate fields or parameters are provided in a request (such as repeated JSON keys in the request body or duplicate query parameters), the last occurrence takes precedence.

request - The metadata request object.

Request parameters:

parent - Required. It contains the Firebase project id (i.e. the unique identifier for your Firebase project), in the format of projects/{project_id}. The numeric project number with no padding is also supported in the format of projects/{project_number}. Value must have pattern ^projects/\[^/\]+$.

$fields - Selector specifying which fields to include in a partial response.

Completes with a Message.

Completes with a commons.ApiRequestError if the API endpoint returned an error.

If the used http.Client completes with an error when making a REST call, this method will complete with the same error.

Implementation

async.Future<Message> send(
  SendMessageRequest request,
  core.String parent, {
  core.String? $fields,
}) async {
  final body_ = convert.json.encode(request);
  final queryParams_ = <core.String, core.List<core.String>>{
    'fields': ?$fields == null ? null : [$fields],
  };

  final url_ = 'v1/' + core.Uri.encodeFull('$parent') + '/messages:send';

  final response_ = await _requester.request(
    url_,
    'POST',
    body: body_,
    queryParams: queryParams_,
  );
  return Message.fromJson(response_ as core.Map<core.String, core.dynamic>);
}