How to use FastButtons for them to work on mobile devices? - google-apps-script

I have read this (and other relating things also):
https://developers.google.com/mobile/articles/fast_buttons?hl=fi#conclusion
but I don't understand how to use this in Google Apps Script. I made the UI with GUI Builder and now I want the buttons to work also on mobile devices.
Could someone please explain to me with a code example of how to change my buttons to work also on mobile devices?
Code that works Ok on PC but not on mobile device:
var handler109 = app.createServerClickHandler('func109');
var but109 = app.getElementById('Button109');
but109.addClickHandler(handler109);
How to use Client Handler? app.createClientHandler('func109') generates an error, app.createClientClickHandler('func109') generates an error... How do I define that function func109 should be called?
var handler109 = app.createClientHandler();
var but109 = app.getElementById('Button109');
but109.addClickHandler(handler109);

First, the article you've shared is applicable for mobile and not so much for Google Apps Scripts.
However, the buttons you make in Google Apps Script WILL work on mobile devices too. However, if you only have a server handler set up on the button, it will take a noticeable period of time before the action of the button is seen by the user.
Google Apps Script also has client handlers which you can use which show up a much faster response than server handlers.
Issue 1086 might be relevant in your case

Related

Script when opening in the mobile version of Google Sheets

It is necessary that, in the mobile version of the Google spreadsheet (on a mobile phone), the script scrolls / activates the bottom cell of the table.
In the desktop version of Google Spreadsheets It works!! :
var ss=SpreadsheetApp.getActiveSpreadsheet();
ss.setActiveSelection('A'+ss.getLastRow());
SpreadsheetApp.flush();
But this script does not work in a mobile phone (maybe due to the reduced capabilities of the mobile version of the table).
But still I hope - Connoisseurs will prompt me something!
Long story short, onOpen() triggers do not work on mobile (as stated by Ryan), nor is there an AppScript or Macro menu. One thing that does work, though, is onEdit() triggers.
From my experience, the only way to accomplish something like this would be to implement an onEdit() function with a checkbox. This method would not be automatic when opening the sheet, but upon opening the sheet on mobile, the user could then check off that box, and the script would run. Let me know if this is a method you would be interested in trying out, and I can edit this post to provide you with some code (I am not providing it initially since it doesn't really answer your question or truly solve your issue).
This probably isn't an issue with your code but the fact that googles mobile apps don't support Google Script or their triggers, Try using the mobile browser view of google sheets that might work.

Gmail workspace add-on Mobile app has no back navigation

We have Gmail Workspace add-on that is used on both the Gmail Web app and Gmail Mobile app.
For some reason when running in the Gmail Mobile app there is no back navigation available. The below screen shot shows the navigation on the Web app.
But this is not available on the Mobile app?
I can't see this difference documented anywhere. Is there something we are not setting to enable this?
Also in addition to the back navigation not being available we get an error whenever we try and set the navigation via app script.
For example the following:
cs.newActionResponseBuilder().setNavigation(cs.newNavigation().popCard()).build()
gives the error on Mobile app only -
failed to complete your action because the add-on will be in a bad
state
Is this behaviour to be expected? Is there some other approach to controlling navigation on Gmail Mobile that we are not aware of?
I found the problem... In case somebody else experiences it.
In my code - the issue is caused when an invoked function returns a card as in the following snippet
function loadStackCard() {
var emailCard = CardService.newCardBuilder().setHeader(CardService.newCardHeader().setTitle('STACK CARD'))
.addSection(CardService.newCardSection().addWidget(CardService.newTextButton().setText('GO BACK')
.setOnClickAction(CardService.newAction().setFunctionName('goBack')))).build();
return emailCard;
}
But when I push the card onto the navigation stack it works on Mobile
function loadStackCard() {
var emailCard = CardService.newCardBuilder().setHeader(CardService.newCardHeader().setTitle('STACK CARD'))
.addSection(CardService.newCardSection().addWidget(CardService.newTextButton().setText('GO BACK')
.setOnClickAction(CardService.newAction().setFunctionName('goBack')))).build();
nav = CardService.newNavigation().pushCard(emailCard) ;
return CardService.newActionResponseBuilder().setNavigation(nav).build();
}

How to disable Gmail add-on on mobile devices?

I do not want my Gmail add-on to be displayed on mobile devices. How can I disable it for mobile devices?
From the forum, it was stated that this action can't be done as per design. You can comment in this thread.
There's no way to turn that off withing the (unmodified) Gmail UI.
Please use the in-app “Send feedback” link to submit your
request/issue directly to Google. You will not receive a response
from Google.
It is possible to hide the Gmail add-on on mobile devices.
Here is an example code snippet that will make something some up on web only, nothing on android:
function prodd(event) {
if (event.clientPlatform.toUpperCase().equals('WEB')) {
return [getClientInfo(event)];
}
return [];
}
You need to make sure that you use a versioned deployment for this code. On HEAD deployment, it'll show an error: "No add-on data returned. This message is only shown in development mode."

Gmail extension/gadget API - how to add a button to the compose toolbar?

I'm trying to figure out how can I add a button to the Gmail compose window.
In "Gmail Labs" they have some extensions that add certain buttons For example "Send & Archive" button and "Inserting images" button, so I assume this is possible.
I checked their API here and it seems that you can either add a gadget to left sidebar or use contextual gadgets that are dependent on the message context. I'm looking for a way to add a button to the toolbar of the compose window, and both options don't seem to support it.
Do you know how can this be done?
If it's not possible using Gmail API, is there another way I can achieve this? Maybe by creating a Google Chrome extension or user scripts?
I would appreciate any info that can direct me in the right direction.
Thanks.
The Gmail Labs have special permissions because they are written by Google Employees, unfortunately we mortals don't have such power. There is a way around it of course and you've correctly pointed out that it is to make a Chrome Extension or a UserScript. If you choose to do a Chrome Extension it will just be a wrapper for a UserScript anyway
You will have to create and inject the button programmatically. This will involve quite a bit of scouring the Gmail source code (spoiler: it's ugly).
Without more details about what you want to do, I won't be able to provide much more help but I can help you with one problem right away. You have to make your script wait until the Gmail loading process is done which is a bit of a challenge. This is the solution I'm currently using in Minimalist:
function bootstrap() {
target = document.querySelectorAll('.vt:not(.SFzvCe)');
if (document.querySelectorAll('html.xiu1Fc, html.aao')[0] == null) {
return;
}
if (target.length > 0) {
// loaded, do stuff
} else {
window.setTimeout(bootstrap, 200);
}
}
window.addEventListener('DOMSubtreeModified', bootstrap);
That version waits for the chat to fully load. Let me know if you have any other questions: #anstosa
You can use InboxSDK for that.
Here is documentation link
Also you have a Hello world repo, where is a solved your problem
hello repo

Execute button inside a ribbon

I want to write a script (C# or AutoIT or VBScript.. whatever works) which should
Get reference of already open outlook application
Iterate through ribbons to find a specific button
Execute that button click
How can I do it?
Use AutomationPeers.
Here is the MSDN article with lots of details:
http://msdn.microsoft.com/en-us/library/ms752331.aspx
Add references to:
UIAutomationClient
UIAutomationClientsideProviders
UIAutomationProvider
UIAutomationTypes
And here is a little C# code snippet of how to get the AutomationId of what currently has focus:
var id = AutomationElement.FocusedElement.Current.AutomationId;
this.txt.Text = id;
You can navigate the entire tree of a window and drive the entire UI using automation peers. This is how accessibility applications interact with applications in Windows. This is also one way that automated UI testing applications do it as well.