Gmail workspace add-on Mobile app has no back navigation - google-apps-script

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();
}

Related

How to access Gmail messages selected (checkbox)

I am trying to build an Add-On for gmail which will perform some actions on a set of messages selected by the user.
Looking at the gmail Apps Script API, I cannot see a method that allows me to do that.
I've noticed that some AddOns operate on selected messages, just like what I want to do. See picture below...
The checkboxes (highlighted in green) tell the AddOn what to operate on.
What am I missing?
The opened menu has options to forward the messages selected by combining them.
Also, I noticed that this AddOn is placed by google along the top. The same happen to the boomerange AddOn. The AddOn I am developing, always appears on the right hand side (pink arrows).
How can you place your addOn along the top menu?
The items you reference with the orange arrows in the image are not Gmail Add-ons, they are actually Chrome Extensions. Chrome Extensions are installed in the browser and they can add functionality by manipulating the DOM (Document Object Model) of a webpage. The chrome extension in question is probably specifically targeting chrome tabs with Gmail loaded and injecting content in the respective pages.
If you want to learn more about developing Chrome Extensions check out the following documentation:
https://developer.chrome.com/extensions/devguide
And for developing gmail specific Chrome Extensions you might want to check out the InboxSDK framework linked below:
https://www.inboxsdk.com/

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."

how to cancel or back up from google drive signin in iOS

I'm using the standard OAuth2 viewControllerTouch for user login in my iOS app. What are some ways to implement a "back" or "cancel" to return the UI to my app if the user gets frustrated and can't complete the login?
Take a look at the sample included in gtm-OAuth2. The short answer is when you create the controller you should be pushing it on to a navigation controller. The navigation bar should provide the back/cancel functionality.

How to use FastButtons for them to work on mobile devices?

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

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