-2

How I can connect and sync with Google Contacts? How do I use google calendar?

Pavel Shkleinik
  • 6,298
  • 2
  • 24
  • 36

2 Answers2

2

You can try this simple example that shows how to add a Contact to your Google Account using App Maker. For this, I am using the “addToGroup(group)” method as explained here https://developers.google.com/apps-script/reference/contacts/contact#addtogroupgroup

  1. Create a new App Maker application.
  2. Add a new Server Script to your App Maker app and add the following code:
function addContact() {
 // The code below creates a new contact and then adds it to the contact group named
 // "My Contacts"
 var contact = ContactsApp.createContact('John', 'Doe', 'john.doe@example.com');
 var group = ContactsApp.getContactGroup('System Group: My Contacts');
 contact = contact.addToGroup(group);
}
  1. Create a new "Page" in App Maker and add a Button widget
  2. Select the Button widget and using the Property editor, choose "onClick" > Custom Action
  3. Add the following code to the onClick custom action:
function onSuccess() {   
console.log("New Contact added succesfully"); 
}
google.script.run.withSuccessHandler(onSuccess).addContact();

Note that in order to call a server script, you will need to use google.script.run as explained here https://developers.google.com/appmaker/scripting/client#call_a_server_script

  1. Preview you App Maker application
  2. Click the Button widget and the new contact will be added under "My Contacts" here https://contacts.google.com/

Hope this helps!

Wilmar
  • 273
  • 2
  • 8
0

App Maker runs on Apps Script. So you can write a server-side script using the normal Apps Script APIs to accomplish this. See https://developers.google.com/apps-script/reference/.

Devin Taylor
  • 825
  • 5
  • 11