我正在使用卡服务开发 Gmail 插件,并尝试实现一个弹出窗口,该弹出窗口会在插件内发生特定事件时显示。我想在此弹出窗口中向用户提供附加信息*或选项。
我浏览了 Google Apps 脚本文档和 Gmail 插件指南,但找不到在 Gmail 插件上下文中创建弹出窗口的简单方法。
理想情况下,我希望当用户单击特定按钮或在附加组件中执行特定操作时出现弹出窗口。为此,我应该使用哪些函数或库?有任何代码示例或教程可以帮助我入门吗?
有人可以指导我如何使用卡服务向 Gmail 插件添加弹出窗口吗?
建议:
您可以使用类通知生成通知弹出框并将其绑定到您的按钮操作。以下是使用 Gmail 卡服务快速入门 指南“猫”
的示例实现使用该函数的示例修改版本:
function onChangeCat(e) {
console.log(e);
// Get the text that was shown in the current cat image. This was passed as a
// parameter on the Action set for the button.
var text = e.parameters.text;
// The isHomepage parameter is passed as a string, so convert to a Boolean.
var isHomepage = e.parameters.isHomepage === 'true';
// Create a new card with the same text.
var card = createCatCard(text, isHomepage);
// Create an action response that instructs the add-on to replace
// the current card with the new one.
var navigation = CardService.newNavigation()
.updateCard(card);
var actionResponse = CardService.newActionResponseBuilder()
.setNavigation(navigation).setNotification(CardService.newNotification()
.setText("This is a test notification message"));
return actionResponse.build();
}
只需在 ActionResponseBuilder 上添加
.setNotification(CardService.newNotification().setText("This is a test notification message"))
并在 setText
方法中设置预定义文本