Truy cập vào bảng điều khiển

Send messages with the Firebase Console

You can send notification messages using the Notifications composer in the Firebase console. Though this does not provide the same flexibility or scalability as sending messages with the Admin SDK or the HTTP and XMPP protocols, it can be very useful for testing or for highly targeted marketing and user engagement. The Firebase console provides analytics-based A/B testing to help refine and improve marketing messages.

After you have developed logic in your app to receive messages, you can allow non-technical users to send messages per the instructions in the Notifications page in the Firebase Help Center.

About FCM message fields in the Notifications composer

When you send a notification message from the Notifications composer, Google uses the values you enter in the form fields in these ways:

  • Fields like User segment and Expires determine the message target and delivery options.
  • Fields like Notification text and Custom data are sent to the client in a payload comprised of key/value pairs.

These fields map to keys available through the FCM server protocols. For example, key/value pairs entered in Custom data are handled as a data payload for the notification. Other fields map directly to keys in the FCM notification payload.

Note that some fields in the Notifications composer are not available through the FCM server protocols. For example, you can target user segments based on app version, language, browser type and version, or user properties in ways that are not available using the to field in the server API.

The keys that the Firebase console sends to clients are:

Key Console field label Description
notification.title Notification title Indicates notification title.
notification.body Notification text Indicates notification body text.
data Custom data Key/value pairs that you define. These are delivered as a data payload for the app to handle.

Keys that determine message delivery include:

Key Console field label Description
sound Sound

Indicates a sound to play when the device receives a notification.

time_to_live Expires

This parameter specifies how long (in seconds) the message should be kept in FCM storage if the device is offline. For more information, see Setting the lifespan of a message.

Audit logs

Firebase services write audit logs to help you answer the questions, "Who did what, where, and when?" These are Cloud Audit Logs, provided as part of the GCP project connected to your Firebase project. Your Firebase projects each contain only the audit logs for resources that are directly within the project.

For a general overview of Cloud Audit Logs, go to Cloud Audit Logs. For a deeper understanding of Cloud Audit Logs, review Understanding audit logs.

Cloud Audit Logs maintains Data Access for each GCP project.

Only if explicitly enabled, Firebase Notifications Console writes Data Access audit logs. Data Access audit logs contain API calls that read the configuration or metadata of resources, as well as user-driven API calls that create, modify, or read user-provided resource data. Data Access audit logs do not record the data-access operations on resources that are publicly shared (available to All Users or All Authenticated Users) or that can be accessed without logging into GCP .

Audited operations

The following table summarizes which console action (and type name) correspond to each audit log type in Firebase Notifications Console . We can use the type name from the console action to search for a specific log.

Audit logs category Firebase Notifications Console actions Type name(used to search on the UI for logs)
Data Access logs (DATA_READ) Get a campaign GetCampaign
Data Access logs (DATA_READ) List campaigns ListCampaign
Data Access logs (DATA_READ) Get information from a ABT experiment notification LegacyGetRollout
Data Access logs (DATA_READ) Get targeting possibilities GetAudiences
Data Access logs (DATA_READ) Get fcm stats (Sent/Opened/Delivered/Converted counts) GetFcmStats
Data Access logs (DATA_READ) Get list of analytics labels for a date range and project. GetAnalyticsLabelList
Data Access logs (DATA_WRITE) Create a campaign CreateCampaign
Data Access logs (DATA_WRITE) Delete a campaign DeleteCampaign
Data Access logs (DATA_WRITE) Update a Campaign UpdateCampaign
Data Access logs (DATA_WRITE) Create Rollout From ABT LegacyCreateRollout

Audit log format

Audit log entries—which can be viewed in Stackdriver Logging using the Logs Viewer, the Stackdriver Logging API, or the Cloud SDK—include the following objects:

  • The log entry itself, which is an object of type LogEntry. Useful fields include the following:

    • logName contains the project identification and audit log type
    • resource contains the target of the audited operation
    • timeStamp contains the time of the audited operation
    • protoPayload contains the audited information
  • The audit logging data, which is an AuditLog object held in the protoPayload field of the log entry.

  • Optional service-specific audit information, which is a service-specific object held in the serviceData field of the AuditLog object. For details, go to Service-specific audit data.

For other fields in these objects, plus how to interpret them, review Understanding audit logs.

Log name

Cloud Audit Logs resource names indicate the project or other entity that owns the audit logs. For example, the following shows log name for a project's Data Access audit logs:

projects/[PROJECT_ID]/logs/cloudaudit.googleapis.com%2Fdata_access

Service name

Firebase Notifications Console audit logs use the service name gcmcontextualcampaign-pa.googleapis.com.

For more details on logging services, go to Mapping services to resources.

Resource types

Firebase Notifications Console audit logs use the resource type audited_resource for all audit logs.

For a full list, go to Monitored resource types.

Enabling audit logging

Data Access audit logs are disabled by default and are not written unless explicitly enabled (the exception is Data Access audit logs for BigQuery, which cannot be disabled).

For instructions on enabling some or all of your Data Access audit logs, go to Configuring data access Logs.

The Data Access audit logs that you enable can affect your logs pricing in stackdriver_name_short. Review the Pricing section on this page.

Audit log permissions

Cloud Identity and Access Management permissions and roles determine which audit logs you can view or export. Logs reside in projects and in some other entities including organizations, folders, and billing accounts. For more information, go to Understanding roles.

To view Admin Activity audit logs, you must have one of the following Cloud IAM roles in the project that contains your audit logs:

To view Data Access audit logs, you must have one of the following roles in the project that contains your audit logs:

Viewing logs

You have several options for viewing your audit log entries:

Basic Viewer

You can use the Logs Viewer basic interface in the GCP Console to retrieve your audit log entries. Do the following:

  1. Go to the Stackdriver Logging > Logs (Logs Viewer) page in the GCP Console:

    Go to the Logs Viewer page

  2. Select an existing GCP project at the top of the page, or create a new project.

  3. In the first drop-down menu, select the resource type whose audit logs you wish to view. You can select a specific resource or Global for all resources.

  4. In the second drop-down menu, select the log type you want to view: data_access for Data Access audit logs.

    If none of these options are displayed, then there are no audit logs of that type available in the project.

  5. If you want to search for a specific type of log, for example, the logs correlated with creating a campaign you can filter by the type name, in this case, it will be: CreateCampaign.

Advanced Viewer

You can use the Logs Viewer advanced interface in the GCP Console to retrieve your audit log entries. Do the following:

  1. Go to the Stackdriver Logging > Logs (Logs Viewer) page in the GCP Console:

    Go to the Logs Viewer page

  2. Select an existing GCP project at the top of the page, or create a new project.

  3. In the first drop-down menu, select the resource type whose audit logs you wish to view. You can select a specific resource or Global for all resources.

  4. Click the drop-down arrow (▾) at the far right of the search-filter box and select Convert to advanced filter.

  5. Create a filter that further specifies the log entries you want to view. To retrieve all audit logs in your project, add the following filter. Supply a valid [PROJECT_ID] in each of the log names.

      logName = ("projects/[PROJECT_ID]logs/cloudaudit.googleapis.com%2Fdata_access")
    

    For more details about filters, go to Advanced logs filters.

API

To look at your audit log entries using the Stackdriver Logging API:

  1. Go to the Try this API section in the documentation for the entries.list method.

  2. Put the following into the Request body part of the Try this API form. Clicking on this prepopulated form automatically fills the request body, but you will need to supply a valid [PROJECT_ID] in each of the log names.

      {
        "resourceNames": [
          "projects/[PROJECT_ID]"
        ],
        "pageSize": 5,
        "filter": "logName=(projects/[PROJECT_ID]/logs/cloudaudit.googleapis.com%2Fdata_access)"
      }
    
  3. Click Execute.

For more details about filters, go to Advanced logs filters.

SDK

To read your log entries using the Cloud SDK, run the following command. Supply a valid [PROJECT_ID] in each of the log names.

gcloud logging read "projects/[PROJECT_ID]/logs/cloudaudit.googleapis.com%2Fdata_access)"

Go to Reading log entries for more information about using the Cloud SDK.

For a sample audit log entry and how to find the most important information in it, go to Understanding audit logs.

Exporting audit logs

You can export audit logs in the same way you export other kinds of logs. For details about how to export your logs, go to Exporting logs. Here are some applications of exporting audit logs:

  • To keep audit logs for a longer period of time or to use more powerful search capabilities, you can export copies of your audit logs to Google Cloud Storage, BigQuery, or Google Cloud Pub/Sub. Using Cloud Pub/Sub, you can export to other applications, other repositories, and to third parties.

  • To manage your audit logs across an entire organization, you can create aggregated export sinks that can export logs from any or all projects in the organization.

  • If your enabled Data Access audit logs are pushing your projects over their logs allotments, you can export and exclude the Data Access audit logs from Logging. For details, go to Excluding logs.

Pricing

Stackdriver Logging does not charge you for audit logs that are always generated and cannot be disabled, including all Admin Activity audit logs.

Stackdriver Logging charges you for Data Access audit logs that you explicitly request.

For more information on audit logs pricing, review Stackdriver pricing.