Search code examples
gmailgmail-addons

How to save user preferences?


We're developing a Gmail Addon to help internal staff to handle customers' email.

Our card widget will have a table with 2 column; first cell of every row will host, one or more domains, and the 2nd one will contains an editable text box with the default label that the addon will add to this user.

I'd like to allow user to change the default label, to adapt to his/her preferences and actual labelling method, adopted in some cases since years.

So the problem: how to save the user preferences, the user settings, of our addon only of course, but keeping related to user account? The goal is allow user to login with different devices and find the same settings


Solution

  • The sample Gmail add-ons projects that Google have published on Github should help you. In particular I've just found this Settings.js source file.

    The core seems to be

    var savedSettings = cachedPropertiesForUser_().get("settings", {});
    

    But I've not used this in anger.