Class Notification

  • Notifications inform users about the results of their interactions, such as clicking a button.

  • Developers can use setText() to customize the notification's message.

  • The notification is triggered by a function, which is set as an action on a UI element.

  • notificationCallback() showcases how to build and display a notification to the user.

Notification

A notification shown to the user as a response to interacting with a UI element.

const action = CardService.newAction().setFunctionName('notificationCallback');
CardService.newTextButton().setText('Save').setOnClickAction(action);

// ...

function notificationCallback() {
  return CardService.newActionResponseBuilder()
      .setNotification(
          CardService.newNotification().setText('Some info to display to user'),
          )
      .build();
}

Methods

MethodReturn typeBrief description
setText(text)NotificationSets the text to show in the notification.

Detailed documentation

setText(text)

Sets the text to show in the notification. Required.

Parameters

NameTypeDescription
textStringThe notification text.

Return

Notification — This object, for chaining.