Google 附加功能:使用第一张加载的卡片显示通知

问题描述 投票:0回答:0

Google add on initialization works with a function being called, the function is defined in the appscript JSON :

"addOns": {
    "common": {
      "name": "name of add on",
      "homepageTrigger": {
        "runFunction": "onLoad",
        "enabled": true
      },

onLoad 函数必须返回一个内置的 Card (CardService.newCardBuilder().build())。

我想这样做,以便构建的初始卡也发送通知(在附加组件上显示为快餐栏几秒钟的临时消息)。

这将通过向动作响应添加通知并构建它来完成。

var card = buildCard();
var navigation = CardService.newNavigation().popCard().pushCard(card);
var actionresponse =  CardService.newActionResponseBuilder()
    .setNavigation(navigation)
    .setNotification(CardService.newNotification()
        .setText(notificationText)
        .setType(CardService.NotificationType.INFO));

return actionresponse.build(); 

但是onLoad函数不接受内置动作响应,需要内置卡片

有什么方法可以克服这个问题吗?

谢谢

google-apps-script notifications initialization add-on
© www.soinside.com 2019 - 2024. All rights reserved.