Class Notification
تنظيم صفحاتك في مجموعات
يمكنك حفظ المحتوى وتصنيفه حسب إعداداتك المفضّلة.
الإشعار
إشعار يُعرَض للمستخدم استجابةً للتفاعل مع عنصر واجهة مستخدم.
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();
}
مستندات تفصيلية
setText(text)
لضبط النص الذي سيتم عرضه في الإشعار مطلوب.
المعلمات
الاسم | النوع | الوصف |
text | String | نص الإشعار |
الإرجاع
Notification
: هذا العنصر، لإنشاء سلسلة.
إنّ محتوى هذه الصفحة مرخّص بموجب ترخيص Creative Commons Attribution 4.0 ما لم يُنصّ على خلاف ذلك، ونماذج الرموز مرخّصة بموجب ترخيص Apache 2.0. للاطّلاع على التفاصيل، يُرجى مراجعة سياسات موقع Google Developers. إنّ Java هي علامة تجارية مسجَّلة لشركة Oracle و/أو شركائها التابعين.
تاريخ التعديل الأخير: 2025-07-26 (حسب التوقيت العالمي المتفَّق عليه)
[null,null,["تاريخ التعديل الأخير: 2025-07-26 (حسب التوقيت العالمي المتفَّق عليه)"],[[["\u003cp\u003eNotifications inform users about the results of their interactions, such as clicking a button.\u003c/p\u003e\n"],["\u003cp\u003eDevelopers can use \u003ccode\u003esetText()\u003c/code\u003e to customize the notification's message.\u003c/p\u003e\n"],["\u003cp\u003eThe notification is triggered by a function, which is set as an action on a UI element.\u003c/p\u003e\n"],["\u003cp\u003e\u003ccode\u003enotificationCallback()\u003c/code\u003e showcases how to build and display a notification to the user.\u003c/p\u003e\n"]]],["The core content details how to create and display a notification to a user interacting with a UI element. A new `Action` is created, and a `TextButton` is linked to it using `setOnClickAction`. The `notificationCallback` function, triggered by the button, builds an `ActionResponse` with a `Notification`. `setText()` method is used to set the notification message text. It takes a string and returns the `Notification` object, permitting method chaining.\n"],null,["# Class Notification\n\nNotification\n\nA notification shown to the user as a response to interacting with a UI element.\n\n```javascript\nconst action = CardService.newAction().setFunctionName('notificationCallback');\nCardService.newTextButton().setText('Save').setOnClickAction(action);\n\n// ...\n\nfunction notificationCallback() {\n return CardService.newActionResponseBuilder()\n .setNotification(\n CardService.newNotification().setText('Some info to display to user'),\n )\n .build();\n}\n``` \n\n### Methods\n\n| Method | Return type | Brief description |\n|-----------------------------------|-------------------|--------------------------------------------|\n| [setText(text)](#setText(String)) | [Notification](#) | Sets the text to show in the notification. |\n\nDetailed documentation\n----------------------\n\n### `set``Text(text)`\n\nSets the text to show in the notification. Required.\n\n#### Parameters\n\n| Name | Type | Description |\n|--------|----------|------------------------|\n| `text` | `String` | The notification text. |\n\n#### Return\n\n\n[Notification](#) --- This object, for chaining."]]